Skip to content

Commit

Permalink
triggers: plug memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed Aug 20, 2021
1 parent 514fde8 commit 727d35f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libpkg/triggers.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ trigger_execute_lua(const char *script, bool sandbox, pkghash *args)
arguments = xcalloc(pkghash_count(args), sizeof(char*));
it = pkghash_iterator(args);
while (pkghash_next(&it)) {
arguments[i++] = it.value;
arguments[i++] = it.key;
}
}
lua_args_table(L, arguments, i);
Expand Down Expand Up @@ -542,7 +542,7 @@ triggers_execute(struct trigger *cleanup_triggers)
pkghash_it it = pkghash_iterator(ctx.touched_dir_hash);
while (pkghash_next(&it)) {
LL_FOREACH(triggers, t) {
trigger_check_match(t, (char *)it.value);
trigger_check_match(t, it.key);
}
/* We need to check if that matches a trigger */
}
Expand Down Expand Up @@ -585,7 +585,8 @@ append_touched_file(const char *path)
return;
*walk = '\0';

pkghash_safe_add(ctx.touched_dir_hash, newpath, newpath, free);
pkghash_safe_add(ctx.touched_dir_hash, newpath, NULL, NULL );
free(newpath);
}

void
Expand Down Expand Up @@ -631,8 +632,7 @@ exec_deferred(int dfd, const char *name)
walk++; /* skip the space */
if (line[linelen -1] == '\n')
line[linelen -1] = '\0';
char *s = xstrdup(walk);
pkghash_safe_add(args, s, s, free);
pkghash_safe_add(args, walk, NULL, NULL);
}
if (script != NULL)
fputs(line, script->fp);
Expand Down

0 comments on commit 727d35f

Please sign in to comment.