From c886b359ba5f05eec6a8da34b55437834b7d80ee Mon Sep 17 00:00:00 2001
From: Panu Matilainen <pmatilai@redhat.com>
Date: Thu, 6 Feb 2020 14:51:14 +0200
Subject: [PATCH] Fix pointer dereference before testing for NULL in
 rpmtdGetNumber()

---
 lib/rpmtd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/rpmtd.c b/lib/rpmtd.c
index e33c8cb53..41c6a50e8 100644
--- a/lib/rpmtd.c
+++ b/lib/rpmtd.c
@@ -210,12 +210,12 @@ const char * rpmtdGetString(rpmtd td)
 
 uint64_t rpmtdGetNumber(rpmtd td)
 {
-    uint64_t val = 0;
-    int ix = (td->ix >= 0 ? td->ix : 0);
-
     if (td == NULL)
 	return 0;
 
+    uint64_t val = 0;
+    int ix = (td->ix >= 0 ? td->ix : 0);
+
     switch (td->type) {
     case RPM_INT64_TYPE:
 	val = *((uint64_t *) td->data + ix);
-- 
2.27.0

