You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2015/10/07 14:45:46 UTC

[06/20] celix git commit: CELIX-261: Fix memory leaks in shell

CELIX-261: Fix memory leaks in shell


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/a29205ab
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/a29205ab
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/a29205ab

Branch: refs/heads/feature/CELIX-237_rsa-ffi
Commit: a29205ab44a8f498dac49d704afea50caa8190b6
Parents: a72cd6f
Author: Bjoern Petri <bp...@apache.org>
Authored: Sat Oct 3 11:22:53 2015 +0200
Committer: Bjoern Petri <bp...@apache.org>
Committed: Sat Oct 3 11:22:53 2015 +0200

----------------------------------------------------------------------
 shell/private/src/help_command.c    | 2 ++
 shell/private/src/inspect_command.c | 6 +++++-
 shell/private/src/update_command.c  | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/a29205ab/shell/private/src/help_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/help_command.c b/shell/private/src/help_command.c
index b2ed30a..0a11ba9 100644
--- a/shell/private/src/help_command.c
+++ b/shell/private/src/help_command.c
@@ -75,6 +75,7 @@ void helpCommand_execute(command_pt command, char * line, void (*out)(char *), v
 					out(outString);
 				}
 				out("\nUse 'help <command-name>' for more information.\n");
+				arrayList_destroy(commands);
 			} else {
 				bool found = false;
 				while (sub != NULL) {
@@ -99,6 +100,7 @@ void helpCommand_execute(command_pt command, char * line, void (*out)(char *), v
 						}
 					}
 					sub = strtok_r(NULL, delims, &save_ptr);
+					arrayList_destroy(commands);
 				}
 			}
 		}

http://git-wip-us.apache.org/repos/asf/celix/blob/a29205ab/shell/private/src/inspect_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c
index bac1ed9..15bcf3e 100644
--- a/shell/private/src/inspect_command.c
+++ b/shell/private/src/inspect_command.c
@@ -98,6 +98,7 @@ void inspectCommand_execute(command_pt command, char * commandline, void (*out)(
 				sprintf(outString, "%s\n", command->usage);
                 out(outString);
 			}
+			arrayList_destroy(ids);
 		} else {
 			out("INSPECT: Too few arguments\n");
 			sprintf(outString, "%s\n", command->usage);
@@ -133,6 +134,7 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 				out(line);
 			}
 		}
+		arrayList_destroy(bundles);
 	}
 
 	if (status == CELIX_SUCCESS) {
@@ -192,7 +194,6 @@ celix_status_t inspectCommand_printExportedServices(command_pt command, array_li
 		}
 	}
 
-
 	return status;
 }
 
@@ -277,6 +278,7 @@ celix_status_t inspectCommand_printImportedServices(command_pt command, array_li
                                         sprintf(line, "%s = %s\n", key, value);
                                         out(line);
                                     }
+                                    free(keys);
 
 //                                  objectClass = properties_get(props, (char *) OSGI_FRAMEWORK_OBJECTCLASS);
 //                                  sprintf(line, "ObjectClass = %s\n", objectClass);
@@ -292,6 +294,8 @@ celix_status_t inspectCommand_printImportedServices(command_pt command, array_li
         }
     }
 
+    arrayList_destroy(bundles);
+
 
     return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/a29205ab/shell/private/src/update_command.c
----------------------------------------------------------------------
diff --git a/shell/private/src/update_command.c b/shell/private/src/update_command.c
index 9ddfba0..711798d 100644
--- a/shell/private/src/update_command.c
+++ b/shell/private/src/update_command.c
@@ -102,7 +102,7 @@ celix_status_t updateCommand_download(command_pt command, char * url, char **inp
 	curl = curl_easy_init();
 	if (curl) {
 		FILE *fp = NULL;
-		*inputFile = "updateXXXXXX";
+		snprintf(*inputFile, 13,"updateXXXXXX");
 		int fd = mkstemp(*inputFile);
 		if (fd) {
 		    fp = fopen(*inputFile, "wb+");