Blob Blame History Raw
From 958cb3f52a128c0c1720d2a40a5b98a0c7625ee0 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
Date: Fri, 23 Aug 2019 12:42:42 +0200
Subject: [PATCH] Fix "microdnf --help" coredump

There was a bug that causes coredump during comand "microdnf --help".
The bug was in the code that removes the directory path from argv[0]
(in case argv[0] does not contain '/' character).
---
 dnf/dnf-main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/dnf/dnf-main.c b/dnf/dnf-main.c
index 8417f5a..a615e37 100644
--- a/dnf/dnf-main.c
+++ b/dnf/dnf-main.c
@@ -278,8 +278,8 @@ main (int   argc,
   
   if (cmd_name == NULL && show_help)
     {
-      const char *prg_name = strrchr(argv[0], '/') + 1;
-      prg_name = prg_name ? prg_name : argv[0];
+      const char *prg_name = strrchr(argv[0], '/');
+      prg_name = prg_name ? prg_name + 1 : argv[0];
 
       g_set_prgname (prg_name);
       g_autofree gchar *help = g_option_context_get_help (opt_ctx, TRUE, NULL);
--
libgit2 0.28.2