bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Small fix for limited number of strings (and pote


From: Tim Rühsen
Subject: Re: [Bug-wget] [PATCH] Small fix for limited number of strings (and potential garbage value) in arguments to concat_strings
Date: Fri, 17 Oct 2014 13:24:23 +0200
User-agent: KMail/4.14.1 (Linux/3.16-2-amd64; KDE/4.14.1; x86_64; ; )

Am Donnerstag, 16. Oktober 2014, 21:50:50 schrieb Pär Karlsson:
> Hi, I fould a potential gotcha when playing with clang's code analysis tool.
> 
> The concat_strings function silently stopped counting string lengths when
> given more than 5 arguments. clang warned about potential garbage values in
> the saved_lengths array, so I redid it with this approach.
> 
> All tests working ok with this patch.

Hi Pär,

good catch.

Though it is a false positive from clang (the programmer wanted the function 
to be like it is ;-)), I strongly appreciate your patch, transforming 
concat_strings() into a generalized function.


Maybe you can use preallocation mechanism to to avoid realloc() on each loop 
iteration !?. E.g. allocate 5*sizeof(int) with the first malloc and only call 
realloc when the space is depleted...

(Introducing strlcpy() would even allow to avoid 'saved_lengths' - but maybe 
that  is too much right now.)

Just my thoughts.

Tim


> This is my first patch to this list, by the way. I'd be happy to help out
> more in the future.

Welcome to Wget !
We appreciate any help. I want to start cleaning up the bug list - if you are 
looking for appropriate jobs, have a look into
        http://savannah.gnu.org/bugs/?group=wget

Feel free to ask questions. We'll try to answer them and like to support your 
work.

Tim

Attachment: signature.asc
Description: This is a digitally signed message part.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]