Re: minor memory leak risk
Daniel Stenberg [EMAIL PROTECTED] writes: This subject says it all. The leak is minor, the fix could be made something like this: What memory leak are you referring to in the subject? Your patch replaces an assert() with a return NULL. The only way that assert() could be tripped is by having a line begin with \0 (which I didn't think of when I was writing the code; I was guarding against an impossible condition to protect the logic of the code.)
Re: minor memory leak risk
[EMAIL PROTECTED] writes: It's not just a memory leak. Length = 0 is declared as a can't happen. If length is zero, wget will suddenly end due to the assert. If a bad input file can lead to length being zero, then using assert is bad on principle. One should never assert external input. For the record, I agree with all you said here. The assert was not meant to guard against external input. As I said in the previous message, I now see a way for LENGTH to be zero, so I will remove the assert. Before I do that, I'd like to understand what problem Daniel was trying to fix, just in case I missed something.
Re: minor memory leak risk
Daniel Stenberg [EMAIL PROTECTED] writes: You're right of course. Hm. No, it can probably only happen if the first byte in an existing file is a zero-byte, so that strlen() return 0... Yup. Or the first byte of any line. I.e. Wget will die if it encounters the \n\0 sequence of characters, which is a bug. This should be fixed by replacing the assert with continue. That line may be impossible to process given the standard handling of C strings, but it doesn't mean that other lines in the file cannot be used.