summaryrefslogtreecommitdiff
path: root/lib/rpmds.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-06-09 09:31:00 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-06-09 09:31:00 +0300
commit94552b96256c3620b4be407c501d0d926c081963 (patch)
treeb595ea2639ca0cd81d1b09a8677ca7e79e2e06ff /lib/rpmds.c
parentd4c04512a15733ebfababd42b67d957744e613b9 (diff)
downloadlibrpm-tizen-94552b96256c3620b4be407c501d0d926c081963.tar.gz
librpm-tizen-94552b96256c3620b4be407c501d0d926c081963.tar.bz2
librpm-tizen-94552b96256c3620b4be407c501d0d926c081963.zip
Handle NULL in str2hge()
- at least apt-rpm expects to pass empty version as NULL to rpmdsSingle(), don't blow up...
Diffstat (limited to 'lib/rpmds.c')
-rw-r--r--lib/rpmds.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 565dace9a..2d49ec692 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -90,10 +90,16 @@ static int dsType(rpmTag tag,
static const char ** str2hge(const char *str)
{
const char ** arr;
- char *t = xmalloc(sizeof(*arr) + strlen(str) + 1);
+ size_t slen = str ? strlen(str) + 1 : 0;
+ char *t = xmalloc(sizeof(*arr) + slen);
arr = (const char **) t;
- t += sizeof(*arr);
- strcpy(t, str);
+
+ if (str) {
+ t += sizeof(*arr);
+ strcpy(t, str);
+ } else {
+ t = NULL;
+ }
arr[0] = t;
return arr;
}