On 01/12/17 at 09:39pm, Allan McRae wrote:
On 03/01/17 01:19, Stefan Klinger wrote:
In hook definition files, repeated assignment to Description, Exec, Type, and When silently overwrote previous settings. This yields a warning now.
Signed-off-by: Stefan Klinger <git@stefan-klinger.de> ---
On closer review.... y ou have exposed two memory leaks here. Please fix and resubmit.
Thanks, Allan
<snip>
} else if(strcmp(key, "Description") == 0) { + if(hook->desc != NULL) { + warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "Description"); + }
FREE(hook->desc);
STRDUP(hook->desc, value, return 1); } else if(strcmp(key, "Depends") == 0) { char *val; @@ -330,12 +340,15 @@ static int _alpm_hook_parse_cb(const char *file, int line, } else if(strcmp(key, "NeedsTargets") == 0) { hook->needs_targets = 1; } else if(strcmp(key, "Exec") == 0) { + if(hook->cmd != NULL) { + warning(_("hook %s line %d: overwriting previous definition of %s\n"), file, line, "Exec"); + }
_alpm_wordsplit_free(hook->cmd);
if((hook->cmd = _alpm_wordsplit(value)) == NULL) { if(errno == EINVAL) { error(_("hook %s line %d: invalid value %s\n"), file, line, value); } else { error(_("hook %s line %d: unable to set option (%s)\n"), - file, line, strerror(errno)); + file, line, strerror(errno));
While you're at it, undo this change.
} } } else {