char gratis *: siguiente tamaño no válido (rápido) [duplicado]
Esta pregunta ya tiene una respuesta aquí:
Frente a un error "*** glibc detectado *** libre (): siguiente tamaño no válido (rápido)" 2 respuestasEstoy liberando un char * después de un proceso de concatenación.
Pero recibo este error:
libre (): siguiente tamaño no válido (rápido): 0x0000000001b86170
Abajo está mi código:
void concat(stringList *list) {
char *res = (char*)malloc(sizeof(char*));
strcpy(res, list->head->string);
list->tmp = list->head->next;
while (list->tmp != NULL) {
strcat(res, ",");
strcat(res, list->tmp->string);
list->tmp = list->tmp->next;
}
printf("%s\n", res);
free(res);
}