[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/3] fix memory leak of status_info in module_main.c
From: |
Andrei Kholodnyi |
Subject: |
[PATCH 3/3] fix memory leak of status_info in module_main.c |
Date: |
Thu, 30 Sep 2010 01:05:56 +0200 |
status_info was not freed properly
also if/else is replaced with if since it has a return inside
Thanks Halim Sahin for reporting this problem
---
src/modules/module_main.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/modules/module_main.c b/src/modules/module_main.c
index b50d72a..7bc7774 100644
--- a/src/modules/module_main.c
+++ b/src/modules/module_main.c
@@ -129,15 +129,15 @@ main(int argc, char *argv[])
}
if (!strcmp(cmd_buf, "INIT\n")){
- if (ret_init == 0){
- printf("299-%s\n", status_info);
- ret = printf("%s\n", "299 OK LOADED SUCCESSFULLY");
- }else{
+ if (ret_init != 0){
printf("399-%s\n", status_info);
ret = printf("%s\n", "399 ERR CANT INIT MODULE");
+ g_free(status_info);
return -1;
}
- g_free(status_info);
+
+ printf("299-%s\n", status_info);
+ ret = printf("%s\n", "299 OK LOADED SUCCESSFULLY");
if (ret < 0){
DBG("Broken pipe, exiting...\n");
@@ -148,6 +148,8 @@ main(int argc, char *argv[])
DBG("ERROR: Wrong communication from module client: didn't call
INIT\n");
module_close(3);
}
+
+ g_free(status_info);
g_free(cmd_buf);
while(1){
--
1.6.0.4