Skip to content

Commit a65e242

Browse files
committed
Refactored cleanup section of _xccdf_fix_execute.
`fix_text` is allocated in `_xccdf_fix_decode_xml` and was possibly freed in `_write_text_to_fd_and_free`, but in meantime could have been be jumped over free, causing a memory leak.
1 parent c071dfb commit a65e242

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/XCCDF_POLICY/xccdf_policy_remediate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ static inline int _xccdf_fix_execute(struct xccdf_rule_result *rr, struct xccdf_
378378
goto cleanup;
379379
}
380380

381-
if (_write_text_to_fd_and_free(fd, fix_text) != 0) {
381+
if (_write_text_to_fd(fd, fix_text) != 0) {
382382
_rule_add_info_message(rr, "Could not write to the temp file: %s", strerror(errno));
383383
(void) close(fd);
384384
goto cleanup;
@@ -440,6 +440,7 @@ static inline int _xccdf_fix_execute(struct xccdf_rule_result *rr, struct xccdf_
440440

441441
cleanup:
442442
oscap_acquire_cleanup_dir(&temp_dir);
443+
free(fix_text);
443444
return result;
444445
}
445446

0 commit comments

Comments
 (0)