"Edward J. Sabol" <[EMAIL PROTECTED]> writes:
> I think there's a valid point here. The memory allocation part of
> the question was misleading though. There is a memory leak in
> url_equal() if the second parseurl() returns a value other than
> URLOK.
Ah, right, of course.
> But I guess this is a completely pedantic issue. I don't see any
> code in wget that even uses url_equal(), or am I missing something?
According to the ChangeLog, it was used by retrieve_url to check if an
HTTP response redirects us back to itself. Later I added more
sophisticated redirection loop detections which no longer relied on
url_equal.
It should probably be #ifdef'ed out, with your fix applied.
> While we're being pedantic though, it seems to me that the return
> values for url_equal() were poorly chosen with both the "not equal"
> condition and the error condition defined to be the same return
> value.
Actually, this might have been by design. If I can reproduce my
thought processes from years ago, the function was meant to be
"robust", and behave equally well with garbage as with real URLs.
Now, if you feed it real URLs, you will get sensible behaviour. If
you feed it garbage, it cannot really know whether the URLs are equal
or not, so it conservatively assumes that they are not equal. (The
"conservative" part would have been more convincing if the function at
least tried to run a simple strcmp between url1 and url2 before trying
anything else.)
I'm not saying that this makes sense or that it's good design; I'm
trying to explain what I probably thought in the long cold January
nights in 1997.