gtk-gnutella logo
поточна версія: 1.2.3

Code 101 - Answers

Test 1

Author: Richard Eckart

Answer

The downloaders always provided the header "User-Agent" and not "Server". Thus the wrong test in line 13 always overwrote the extracted useragent string from the "User-Agent" header with NULL because the "Server" header was not available.

Line 13 should have read

13: if (user_agent == NULL)

That bug was in CVS on 2004-01-17 in uploads.c line 2088.

Test 2

Author: Richard Eckart

Answer

The for-loop iterates over data_list directly, instead of using a helper variable. Because of this at the end of the loop data_list points to NULL. Calling g_list_free() on NULL has exactly no effect and we don't even have a pointer to the list left at the end of the procedure.

To fix the problem, I changed to code to use a helper variable to iterate over data_list, so that I still have the pointer to the beginning of the list in data_list.

That bug was in CVS on 2004-01-17 in downloads_cb.c line 144. We had the same problem in a few other places too and we could measure a leak of about 1MB size after gtkg had been in regular usage for 3 hours.

Users Love Us Community Choice SF Favourite Community Leader Open Source Excellence SourceForge.net Logo RSS Feed Available Open Hub metrics Coverity Scan Build Status gtk-gnutella at GitHub
gtk-gnutella © 2000-2014 by Yann Grossel, Raphaël Manfredi and various contributors.