[Pidgin] #7047: memory leak and logic error in proxy.c in pidgin 2.5.1

Pidgin trac at pidgin.im
Tue Sep 16 06:50:13 EDT 2008


#7047: memory leak and logic error in proxy.c in pidgin 2.5.1
--------------------------+-------------------------------------------------
 Reporter:  rfan.cn       |        Owner:  nosnilmot
     Type:  patch         |       Status:  new      
Milestone:                |    Component:  libpurple
  Version:  2.5.1         |   Resolution:           
 Keywords:  proxy detect  |  
--------------------------+-------------------------------------------------

Comment(by rfan.cn):

 1. I don't test with Finch, I removed the stderr output saving just as I
 think it is not useful to know it here. If it is not the case, then the
 fix need add some code to deal with stderr problem.

 2. Find some other codes need to be optimized as following:

 {{{

  274         if (!g_spawn_command_line_sync("gconftool-2 -g
 /system/proxy/socks_port",
  275                 &tmp, &err, NULL, NULL))
  276         {
  277             g_free(info.host);
  278             info.host = NULL;
  279             g_free(info.username);
  280             info.username = NULL;
  281             g_free(info.password);
  282             info.password = NULL;
  283             return purple_global_proxy_get_info();
  284         }

 }}}

 Here info.username and info.password already freed, no need do again.

 {{{

 308         if (!g_spawn_command_line_sync("gconftool-2 -g
 /system/http_proxy/authentication_user",
 309                     &info.username, &err, NULL, NULL))
 310         {
 311             g_free(info.host);
 312             info.host = NULL;
 313             g_free(info.username);
 314             info.username = NULL;
 315             return purple_global_proxy_get_info();
 316         }

 }}}

 As it indicated in document, when g_spawn_command_line_sync failure with
 some error, there no data will be returned in standard_output, so when we
 try to free the variables contains in the standard_output, we should check
 whether it is NULL.In this section of codes, when some error occurr in
 g_spawn_command_line_sync, info.username will be NULL, try to free it
 without checking whether it's NULL is dangerous. Here we can remove 313
 and 314 lines, as it was initialized to be NULL before.

 In order to minimize the code change, I make sure the info.host is not
 null after line:270. I create the second version of fix file.please help
 review.

-- 
Ticket URL: <http://developer.pidgin.im/ticket/7047#comment:8>
Pidgin <http://pidgin.im>
Pidgin


More information about the Tracker mailing list