[PATCH] pactree: Fix redundant arrows in Graphviz output

Daniel M. Capella polyzen at archlinux.org
Sun Mar 15 23:51:12 UTC 2020


On March 9, 2020 2:22:06 PM EDT, Sebastian Jakubiak <jakseb.dev at gmail.com> wrote:
> Fix an issue where a dependency and a package providing it were
> connected more than once in --graph output. The code supposed to
> prevent that did not always work due to using dangling pointers.
> 
> Signed-off-by: Sebastian Jakubiak <jakseb.dev at gmail.com>
> ---
> 
> This is how one can find a package to reproduce the bug:
> 
> for pkg in `pacman -Qq`; do
>     pactree -g $pkg | sort | uniq -c | awk '$1 != 1' |
>     grep '' && { echo $pkg; break; }
> done
> 
> Originally, I wanted to check if the value returned by strdup() is not
> null, but the existing code (line 217) does not do that, so I don't
> either.
> 
>  src/pactree.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/pactree.c b/src/pactree.c
> index 9f074fe..cf83326 100644
> --- a/src/pactree.c
> +++ b/src/pactree.c
> @@ -232,7 +232,7 @@ static int register_syncs(void)
>  static void cleanup(int ret)
>  {
>  	alpm_list_free(walked);
> -	alpm_list_free(provisions);
> +	FREELIST(provisions);
>  	alpm_release(handle);
>  
>  	exit(ret);
> @@ -412,7 +412,7 @@ static void print_graph(const char *parentname,
> const char *pkgname, const char
> 		printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname,
> depname);
> 		if(pkgname && strcmp(depname, pkgname) != 0 &&
> !alpm_list_find_str(provisions, depname)) {
> 			printf("\"%s\" -> \"%s\" [arrowhead=none, color=grey];\n", depname,
> pkgname);
> -			provisions = alpm_list_add(provisions, (char *)depname);
> +			provisions = alpm_list_add(provisions, strdup(depname));
>  		}
>  	} else if(pkgname) {
> 		printf("\"%s\" -> \"%s\" [color=chocolate4];\n", parentname,
> pkgname);

Thank you, pushed.

The command you shared didn't work for me, but I reproduced the issue with the nginx package.

--
Best,
Daniel <https://danielcapella.com>


More information about the pacman-contrib mailing list