Skip to content

Commit

Permalink
Plug a memory leak
Browse files Browse the repository at this point in the history
Addressing this OpenScanHub issue:
1. Defect type: RESOURCE_LEAK
5. openscap-1.4.1/src/XCCDF_POLICY/xccdf_policy_remediate.c:726:3: alloc_arg: "oscap_pcre_compile" allocates memory that is stored into "err".
19. openscap-1.4.1/src/XCCDF_POLICY/xccdf_policy_remediate.c:774:2: leaked_storage: Variable "err" going out of scope leaks the storage it points to.
   772|   		oscap_pcre_free(tab[i].re);
   773|
   774|-> 	return ret;
   775|   }
   776|
  • Loading branch information
jan-cerny committed Jan 10, 2025
1 parent 829598a commit f56d975
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/XCCDF_POLICY/xccdf_policy_remediate.c
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ struct blueprint_customizations {

static inline int _parse_blueprint_fix(const char *fix_text, struct blueprint_customizations *customizations)
{
char *err;
char *err = NULL;
int errofs;
int ret = 0;

Expand Down Expand Up @@ -768,6 +768,7 @@ static inline int _parse_blueprint_fix(const char *fix_text, struct blueprint_cu
}

exit:
oscap_pcre_err_free(err);
for (int i = 0; tab[i].pattern != NULL; i++)
oscap_pcre_free(tab[i].re);

Expand Down

0 comments on commit f56d975

Please sign in to comment.