Skip to content

Commit 3b060ec

Browse files
authored
Merge pull request #1209 from mildass/fix_probe_worker_memory_leaks
Add missing 'free' calls to src/OVAL/probes/probe/worker.c (master branch)
2 parents 9359627 + abdd7e6 commit 3b060ec

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/OVAL/probes/probe/worker.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,8 @@ static SEXP_t *probe_obj_eval(probe_t *probe, SEXP_t *id)
396396

397397
rid = SEXP_list_first(res);
398398
if (SEXP_string_cmp(id, rid) != 0) {
399+
SEXP_free(res);
400+
SEXP_free(rid);
399401
return NULL;
400402
}
401403
SEXP_free(res);
@@ -619,6 +621,7 @@ static SEXP_t *probe_set_apply_filters(SEXP_t *cobj, SEXP_t *filters)
619621
SEXP_free(result_items);
620622
SEXP_free(r0);
621623
SEXP_free(r1);
624+
SEXP_free(mask);
622625
return cobj;
623626
}
624627
default:
@@ -1071,32 +1074,36 @@ SEXP_t *probe_worker(probe_t *probe, SEAP_msg_t *msg_in, int *ret)
10711074
SEXP_free(pctx.filters);
10721075
}
10731076

1077+
SEXP_free(probe_in);
1078+
10741079
#ifndef OS_WINDOWS
10751080
/* Revert chroot */
10761081
if (probe->real_root_fd != -1) {
10771082
if (fchdir(probe->real_root_fd) != 0) {
10781083
dE("fchdir failed: %s", strerror(errno));
10791084
close(probe->real_root_fd);
10801085
close(probe->real_cwd_fd);
1086+
SEXP_free(probe_out);
10811087
return NULL;
10821088
}
10831089
close(probe->real_root_fd);
10841090
dI("Leaving chroot mode");
10851091
if (chroot(".") == -1) {
10861092
dE("chroot(\".\") failed: %s", strerror(errno));
10871093
close(probe->real_cwd_fd);
1094+
SEXP_free(probe_out);
10881095
return NULL;
10891096
}
10901097
if (fchdir(probe->real_cwd_fd) != 0) {
10911098
dE("fchdir failed: %s", strerror(errno));
10921099
close(probe->real_cwd_fd);
1100+
SEXP_free(probe_out);
10931101
return NULL;
10941102
}
10951103
close(probe->real_cwd_fd);
10961104
}
10971105
#endif
10981106

1099-
SEXP_free(probe_in);
11001107
SEXP_VALIDATE(probe_out);
11011108

11021109
return (probe_out);

0 commit comments

Comments
 (0)