Stephen Smalley avatar Stephen Smalley committed 300bebb

Eliminate a memory leak.

Need to free the old seapp_contexts if any before reloading.

Change-Id: I66a9c2895518c6224920c9728157a84dc572d31a
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>;

Comments (0)

Files changed (1)

 	struct seapp_context *cur;
 	char *p, *name = NULL, *value = NULL, *saveptr;
 	size_t len;
-	int i = 0, ret;
+	int i = 0, n, ret;
 
 	while ((fp==NULL) && seapp_contexts_file[i])
 		fp = fopen(seapp_contexts_file[i++], "r");
 		return -1;
 	}
 
+	if (seapp_contexts) {
+		for (n = 0; n < nspec; n++) {
+			cur = seapp_contexts[n];
+			free(cur->user);
+			free(cur->seinfo);
+			free(cur->name);
+			free(cur->domain);
+			free(cur->type);
+			free(cur->level);
+			free(cur->sebool);
+		}
+		free(seapp_contexts);
+	}
+
 	nspec = 0;
 	while (fgets(line_buf, sizeof line_buf - 1, fp)) {
 		p = line_buf;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.