Re: [vdr] trouble with asprintf

2008-02-11 Thread Wolfgang Rohdewald
On Montag, 11. Februar 2008, Udo Richter wrote: > Well, that leads to the question whether s is unchanged in case of a -1 > error return, and whether this would work: I can confirm that. The man page however says the value will be undefined. My current understanding is: 1. dont forget to call s

Re: [vdr] trouble with asprintf

2008-02-11 Thread Ludwig Nussel
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 backtrac

Re: [vdr] trouble with asprintf

2008-02-11 Thread Udo Richter
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'

Re: [vdr] trouble with asprintf

2008-02-11 Thread Darren Salt
I demand that Ludwig Nussel may or may not have written... > Darren Salt wrote: >> I demand that Ludwig Nussel may or may not have written... >> [snip] >>> asprintf needs to check for multibyte characters to not cut them in >>> the middle and produce invalid output. >> No - it's encoding-neutral.

Re: [vdr] trouble with asprintf

2008-02-11 Thread Ludwig Nussel
Darren Salt wrote: > I demand that Ludwig Nussel may or may not have written... > > [snip] > > asprintf needs to check for multibyte characters to not cut them in > > the middle and produce invalid output. > > No - it's encoding-neutral. What you want is your own version which does that Try the

Re: [vdr] trouble with asprintf

2008-02-11 Thread Darren Salt
I demand that Ludwig Nussel may or may not have written... [snip] > asprintf needs to check for multibyte characters to not cut them in > the middle and produce invalid output. No - it's encoding-neutral. What you want is your own version which does that (but if you still think that that should b

Re: [vdr] trouble with asprintf

2008-02-11 Thread Wolfgang Rohdewald
On Montag, 11. Februar 2008, Ludwig Nussel wrote: > As you can see it doesn't segfault on asprintf but on free(). I did see that. I did not say it segfaults but it does lead to segfaults. > if(asprintf(...) >= 0) > { > printf(...); > free(...); > } I do not want to change dozens of

Re: [vdr] trouble with asprintf

2008-02-11 Thread Ludwig Nussel
Wolfgang Rohdewald wrote: > My problem code: > > mgDb::Build_cddbid(const mgSQLString& artist) const > { > 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

Re: [vdr] trouble with asprintf

2008-02-11 Thread Ludwig Nussel
Udo Richter wrote: > 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, sinc

Re: [vdr] trouble with asprintf

2008-02-11 Thread Ludwig Nussel
Wolfgang Rohdewald wrote: > since asprintf leads to segfaults if feeded with incorrect UTF-8 characters, It's not asprintf that segfaults but the call to free uninitialized memory afterwards. > I wanted to write a wrapper function which would then check the return value > of asprintf. However I h

Re: [vdr] trouble with asprintf

2008-02-10 Thread Darren Salt
I demand that Wolfgang Rohdewald may or may not have written... > On Sonntag, 10. Februar 2008, Udo Richter wrote: >> 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 u

Re: [vdr] trouble with asprintf

2008-02-10 Thread Wolfgang Rohdewald
On Sonntag, 10. Februar 2008, Udo Richter wrote: > 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 printf and family sometimes have to count ch

Re: [vdr] trouble with asprintf

2008-02-10 Thread Udo Richter
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 backwa

Re: [vdr] trouble with asprintf

2008-02-10 Thread Wolfgang Rohdewald
On Sonntag, 10. Februar 2008, Klaus Schmidinger wrote: > You could use VDR's cString::sprintf() instead. > This is probably also what I am going to do in the VDR core code, > to avoid asprintf() altogether. The single leftover vasprintf() > call in cString::sprintf() can then be made safe. vasprin

Re: [vdr] trouble with asprintf

2008-02-10 Thread Klaus Schmidinger
On 02/10/08 16:06, Wolfgang Rohdewald wrote: > Hi, > > I am making the muggle plugin work with UTF-8 and have a little problem: > > 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 aspr

[vdr] trouble with asprintf

2008-02-10 Thread Wolfgang Rohdewald
Hi, I am making the muggle plugin work with UTF-8 and have a little problem: 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. However I have a problem with the variable argument l