libselinux: Fix security_get_boolean_names build error

When running 'make' from libselinux on Fedora 30 (gcc 9.1.1) the
following error is reported:

bute=const -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -Wstrict-overflow=5
-I../include -D_GNU_SOURCE  -DNO_ANDROID_BACKEND  -c -o booleans.o
booleans.c
booleans.c: In function ‘security_get_boolean_names’:
booleans.c:39:5: error: assuming signed overflow does not occur when
changing X +- C1 cmp C2 to X cmp C2 -+ C1 [-Werror=strict-overflow]
  39 | int security_get_boolean_names(char ***names, int *len)
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:171: booleans.o] Error 1

This is caused by the '--i' in the: 'for (--i; i >= 0; --i)' loop.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
This commit is contained in:
Richard Haines 2019-07-08 14:37:01 +01:00 committed by Nicolas Iooss
parent 120883adf0
commit ee8f7a870c
No known key found for this signature in database
GPG Key ID: C191415F340DAAA0

View File

@ -81,8 +81,10 @@ int security_get_boolean_names(char ***names, int *len)
free(namelist);
return rc;
bad_freen:
for (--i; i >= 0; --i)
free(n[i]);
if (i > 0) {
while (i >= 1)
free(n[--i]);
}
free(n);
bad:
goto out;