Lubos Kardos 177601
From cddf43a56f19711866371f02f378dc4095b0fadd Mon Sep 17 00:00:00 2001
Lubos Kardos 177601
From: Lubos Kardos <lkardos@redhat.com>
Lubos Kardos 177601
Date: Mon, 25 Apr 2016 14:38:47 +0200
Lubos Kardos 177601
Subject: [PATCH 2/2] Fix sigsegv in stringFormat() (rhbz:1316903)
Lubos Kardos 177601
Lubos Kardos 177601
Just skip duping of NULL and return it. Returned NULL is handled in
Lubos Kardos 177601
upper layer.
Lubos Kardos 177601
---
Lubos Kardos 177601
 lib/formats.c | 7 +++++--
Lubos Kardos 177601
 1 file changed, 5 insertions(+), 2 deletions(-)
Lubos Kardos 177601
Lubos Kardos 177601
diff --git a/lib/formats.c b/lib/formats.c
Lubos Kardos 177601
index e3626ed..bad0b2d 100644
Lubos Kardos 177601
--- a/lib/formats.c
Lubos Kardos 177601
+++ b/lib/formats.c
Lubos Kardos 177601
@@ -44,9 +44,12 @@ static char * stringFormat(rpmtd td)
Lubos Kardos 177601
 	case RPM_NUMERIC_CLASS:
Lubos Kardos 177601
 	    rasprintf(&val, "%" PRIu64, rpmtdGetNumber(td));
Lubos Kardos 177601
 	    break;
Lubos Kardos 177601
-	case RPM_STRING_CLASS:
Lubos Kardos 177601
-	    val = xstrdup(rpmtdGetString(td));
Lubos Kardos 177601
+	case RPM_STRING_CLASS: {
Lubos Kardos 177601
+	    const char *str = rpmtdGetString(td);
Lubos Kardos 177601
+	    if (str)
Lubos Kardos 177601
+		val = xstrdup(str);
Lubos Kardos 177601
 	    break;
Lubos Kardos 177601
+	}
Lubos Kardos 177601
 	case RPM_BINARY_CLASS:
Lubos Kardos 177601
 	    val = pgpHexStr(td->data, td->count);
Lubos Kardos 177601
 	    break;
Lubos Kardos 177601
-- 
Lubos Kardos 177601
1.9.3
Lubos Kardos 177601