Udo Richter wrote:
> 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());

The manpage explicitly says that the content of s is undefined in
case of error. So even if it works you can't really count on it. You
can't get around checking the return value.

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   SUSE LINUX Products GmbH, Development
 V_/_  http://www.suse.de/



_______________________________________________
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

Reply via email to