[vdr] trouble with asprintf
Udo Richter
udo_richter at gmx.de
Mon Feb 11 20:50:45 CET 2008
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
More information about the vdr
mailing list