Wolfgang Rohdewald wrote:
char *s; asprintf(&s,"%ld-%.9s",random(),artist.original());
segfaults only if illegal utf8 chars appear in artist.original()
asprintf returns -1, so s is nothing that could be freed, and this gives a nice backtrace:
So its basically just free'ing an uninitialized pointer.
Well, that leads to the question whether s is unchanged in case of a -1 error return, and whether this would work:
char *s = NULL; asprintf(&s,"%ld-%.9s",random(),artist.original());
Cheers,
Udo