libselinux: init_selinux_config(): free resources on error
Found by Infer. selinux_config.c:181: error: Resource Leak resource of type `_IO_FILE` acquired by call to `fopen()` at line 165, column 7 is not released after line 181, column 6. 179. type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1); 180. if (!type) 181. return; ^ 182. end = type + strlen(type) - 1; 183. while ((end > type) && Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
This commit is contained in:
parent
0280a2a70c
commit
9ab27e2180
1 changed files with 6 additions and 1 deletions
|
@ -177,8 +177,11 @@ static void init_selinux_config(void)
|
|||
if (!strncasecmp(buf_p, SELINUXTYPETAG,
|
||||
sizeof(SELINUXTYPETAG) - 1)) {
|
||||
type = strdup(buf_p + sizeof(SELINUXTYPETAG) - 1);
|
||||
if (!type)
|
||||
if (!type) {
|
||||
free(line_buf);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
end = type + strlen(type) - 1;
|
||||
while ((end > type) &&
|
||||
(isspace(*end) || iscntrl(*end))) {
|
||||
|
@ -187,6 +190,8 @@ static void init_selinux_config(void)
|
|||
}
|
||||
if (setpolicytype(type) != 0) {
|
||||
free(type);
|
||||
free(line_buf);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
free(type);
|
||||
|
|
Loading…
Reference in a new issue