[vdr] trouble with asprintf

Udo Richter udo_richter at gmx.de
Sun Feb 10 19:31:44 CET 2008


Wolfgang Rohdewald wrote:
> since asprintf leads to segfaults if feeded with incorrect UTF-8 characters,
> I wanted to write a wrapper function which would then check the return value
> of asprintf. 

I never understood what the problem is with utf8 and asprintf, since 
utf8 is mostly ASCIIZ backwards compatible, and asprintf probably 
doesn't even know the difference between utf8 and ascii. What special 
handling does asprintf with utf8? Is there some example that causes the 
trouble?

Worst case I can imagine would be that there's an invalid 0 byte inside 
an utf8 multibyte char, and even this would just result in an utf8 
string that terminates with an incomplete char - and shouldn't handling 
such crap be the job of whatever processes the utf8 string later on? At 
least IMHO it would be wise to count any 0 byte as string end.


Cheers,

Udo



More information about the vdr mailing list