Skip to contentSkip to conversation

libsemanage: fix memory semanage_fc_sort leak

PATCH New Serge E. Hallyn 1 participant 1 message Jun 8, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 libsemanage: fix memory semanage_fc_sort leak

'temp' is not destroyed on return(-1) in three places before it is linked into head.

thanks,
-serge

src/semanage_store.c renamed from src/semanage_store.c.orig +3 -0
@@ -1969,6 +1969,7 @@ int semanage_fc_sort(semanage_handle_t *
 		temp->path = (char*)strndup(&line_buf[start], regex_len);
 		if (!temp->path) {
 			ERR(sh, "Failure allocating memory.");
+			semanage_fc_node_destroy(temp);
 			semanage_fc_node_list_destroy(head);
 			return -1;
 		}
@@ -2000,6 +2001,7 @@ int semanage_fc_sort(semanage_handle_t *
 			temp->file_type = (char*)strndup(&line_buf[i], type_len);
 			if (!temp->file_type) {
 				ERR(sh, "Failure allocating memory.");
+				semanage_fc_node_destroy(temp);
 				semanage_fc_node_list_destroy(head);
 				return -1;
 			}
@@ -2031,6 +2033,7 @@ int semanage_fc_sort(semanage_handle_t *
 		temp->context = (char*)strndup(&line_buf[start], context_len);
 		if (!temp->context) {
 			ERR(sh, "Failure allocating memory.");
+			semanage_fc_node_destroy(temp);
 			semanage_fc_node_list_destroy(head);
 			return -1;
 		}

--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.