Don't free n[i] when n is NULL
PATCH 1/1 Don't free n[i] when n is NULL
This patch fixes a bug found in booleans.c by Coverity:
When the malloc for n fails, we jump to 'bad:', where we proceed to try to free n[i] even though n is NULL.
booleans.c +3 -2
@@ -70,7 +70,7 @@ int security_get_boolean_names(char ***n * (namelist[i]->d_reclen + 1));if (!n[i]) { rc =-1 ; - goto bad; + goto bad_freen; }strncpy (n[i], namelist[i]->d_name, namelist[i]->d_reclen +1 ); }
@@ -82,12 +82,13 @@ out: }free (namelist);return rc; -bad: +bad_freen:for (i =0 ; i < *len; i++) {if (n[i])free (n[i]); }free (n); +bad: goto out; }
--
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.