[patch 4/4] wordexp: avoid strdup and cleanup memory handling

Peter Rosin peda@lysator.liu.se
Wed Oct 10 16:20:00 GMT 2012


On 2012-10-09 11:58, Corinna Vinschen wrote:
> Hi Peter,
> 
> On Oct  9 10:06, Peter Rosin wrote:
>> [...]
>> @@ -142,11 +148,14 @@ wordexp(const char *words, wordexp_t *pw
>>  
>>        num_words = atoi(tmp);
>>  
>> -      wordv = (char **)realloc(pwordexp->we_wordv,
>> -                               (pwordexp->we_wordc + num_words + offs + 1) * sizeof(char *));
>> +      if (pwordexp->we_wordv)
>> +        wordv = we_wordv_to_ext_wordv(pwordexp->we_wordv);
>                    ^^^^^^^^^^^^^^^^^^^^^
>                    This is supposed to be uppercase, right?

Right. I'm not sure how that ended up in there, but I have tested
this standalone without rebuilding newlib, so I guess I must have
screwed up the code juggling somewhere. I had it lower case first,
as an inline, but made it a macro instead. The reason for not going
with the inline function escapes me at the moment.

But that mixup of course make me unsure if the rest is also as I
intended. I'll get back once I have retested it...

Cheers,
Peter



More information about the Newlib mailing list