[pacman-dev] [PATCH] hooks: warn if reassignment overwrites previous setting

Allan McRae allan at archlinux.org
Thu Jan 12 11:39:28 UTC 2017


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 at 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));
>  				}
>  			}
>  		} else {


More information about the pacman-dev mailing list