memory leaks spotted

"Nektarios K. Papadopoulos" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
After updating from CVS I start having some memory leaks on my smsbox.
allocations were reported to be made from octstr_split_words and
http_header_find_first.

Knowing what my application was requesting kannel to do I tracked them
down in three points. 
But I am not sure this is all.

Anyway, the points where my problems spotted and fixed were

in gw/smsbox.c
====================
in smsbox_req_handle:
some calls to list_destroy, where NULL must be replaced with
octstr_destroy_item as the list_item_destructor_t parameter
_________________________
in smsbox_sendsms_post:
A missing octstr_destroy(dlr_url); at the end.
(actually this must be missing for a long time but I didn't report it
when I first encountered it).


in gwlib/http.c
=================
in client_is_persistent the retrieved header value is never destroied.


A sumarizing diff is atteched.
memory_leaks.diff (application/octet-stream, 2.3 KB)
Index: gw/smsbox.c
===================================================================
RCS file: /home/cvs/gateway/gw/smsbox.c,v
retrieving revision 1.171
diff -u -r1.171 smsbox.c
--- gw/smsbox.c	2002/02/18 11:47:53	1.171
+++ gw/smsbox.c	2002/02/20 17:18:20
@@ -1247,8 +1247,8 @@
         }
     }
     msg_destroy(msg);
-    list_destroy(receiver, NULL);
-    list_destroy(allowed, NULL);
+    list_destroy(receiver, octstr_destroy_item);
+    list_destroy(allowed, octstr_destroy_item);
 
     /* have all receivers been denied by list rules?! */
     if (no_recv == list_len(denied)) {
@@ -1259,7 +1259,7 @@
     if (list_len(failed_id) > 0)
 	goto error;
     
-    list_destroy(failed_id, NULL);
+    list_destroy(failed_id, octstr_destroy_item);
     octstr_destroy(newfrom);
     *status = HTTP_ACCEPTED;
     returnerror = octstr_create("Sent.");
@@ -1274,7 +1274,7 @@
             octstr_format_append(returnerror, " %s", octstr_get_cstr(receiv));
         }
     }               
-    list_destroy(denied, NULL);  
+    list_destroy(denied, octstr_destroy_item);  
     return returnerror;
     
 
@@ -1307,8 +1307,8 @@
     }
 
     octstr_destroy(receiv); 
-    list_destroy(failed_id, NULL);
-    list_destroy(denied, NULL);
+    list_destroy(failed_id, octstr_destroy_item);
+    list_destroy(denied, octstr_destroy_item);
     return returnerror;
 }
 
@@ -1559,6 +1559,7 @@
     octstr_destroy(pass);
     octstr_destroy(udh);
     octstr_destroy(smsc);
+    octstr_destroy(dlr_url);
     octstr_destroy(account);
     return ret;
 }
Index: gwlib/http.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/http.c,v
retrieving revision 1.159
diff -u -r1.159 http.c
--- gwlib/http.c	2002/01/18 18:35:21	1.159
+++ gwlib/http.c	2002/02/20 17:18:54
@@ -1434,12 +1434,18 @@
 	return !use_version_1_0;
     } else {
         if (use_version_1_0) {
-	    if (octstr_compare(h, octstr_imm("keep-alive")) == 0)
+	    if (octstr_compare(h, octstr_imm("keep-alive")) == 0) {
+		octstr_destroy(h);
 	        return 1;
-	    else
+	    } else {
+		octstr_destroy(h);
 		return 0;
-	} else if (octstr_compare(h, octstr_imm("close")) == 0)
+	    }
+	} else if (octstr_compare(h, octstr_imm("close")) == 0) {
+	    octstr_destroy(h);
 	    return 0;
+	}
+	octstr_destroy(h);
     }
 
     return 1;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.