From 1701ad8ccccae6f8867a862e074ca30f6583e69f 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 e35ace0..7c71bd0 100644
--- a/dnf/dnf-main.c
+++ b/dnf/dnf-main.c
@@ -298,8 +298,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);
--
2.24.0