Revision
23016
Author
zarzycki@apple.com
Date
2007-01-22 12:56:54 -0800 (Mon, 22 Jan 2007)

Log Message

Fix a small memory management related bug.

Modified Paths

Diff

Modified: trunk/launchd/src/launchd_core_logic.c (23015 => 23016)


--- trunk/launchd/src/launchd_core_logic.c	2007-01-22 20:55:07 UTC (rev 23015)
+++ trunk/launchd/src/launchd_core_logic.c	2007-01-22 20:56:54 UTC (rev 23016)
@@ -1961,9 +1961,12 @@
 	struct kinfo_proc *kp = malloc(len);
 	uid_t u = j->mach_uid;
 
-	if (!job_assumes(j, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) {
+	if (!job_assumes(j, kp != NULL)) {
 		return;
 	}
+	if (!job_assumes(j, sysctl(mib, 3, kp, &len, NULL, 0) != -1)) {
+		goto out;
+	}
 
 	kp_cnt = len / sizeof(struct kinfo_proc);
 
@@ -1980,6 +1983,7 @@
 				kp[i].kp_proc.p_pid, kp[i].kp_proc.p_comm, i_uid, i_euid, i_svuid);
 	}
 
+out:
 	free(kp);
 }