diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-09-11 11:19:23 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-09-11 11:19:23 +0300 |
commit | b89a83682942aeed19471649d89f1e54523c8cee (patch) | |
tree | 32e1349f8573bc5416156071f54ad6a8576cf0ab | |
parent | c5b6ad0464f543e8437dd36d768b4297fbb7dbcc (diff) | |
download | librpm-tizen-b89a83682942aeed19471649d89f1e54523c8cee.tar.gz librpm-tizen-b89a83682942aeed19471649d89f1e54523c8cee.tar.bz2 librpm-tizen-b89a83682942aeed19471649d89f1e54523c8cee.zip |
Eliminate assert()'s from rpmdsMerge()
- These "can't happen" cases where EVR/Flags in source ds are missing
are just as easy to handle as is dying, handling is saner...
-rw-r--r-- | lib/rpmds.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c index 0c54633b1..acde4a619 100644 --- a/lib/rpmds.c +++ b/lib/rpmds.c @@ -550,12 +550,19 @@ int rpmdsMerge(rpmds * dsp, rpmds ods) if (ds == NULL) return -1; + /* Ensure EVR and Flags exist */ + if (ds->EVR == NULL) + ds->EVR = xcalloc(ds->Count, sizeof(*ds->EVR)); + if (ds->Flags == NULL) + ds->Flags = xcalloc(ds->Count, sizeof(*ds->Flags)); + /* * Add new entries. */ save = ods->i; ods = rpmdsInit(ods); while (rpmdsNext(ods) >= 0) { + const char *OEVR; /* * If this entry is already present, don't bother. */ @@ -573,16 +580,13 @@ int rpmdsMerge(rpmds * dsp, rpmds ods) } ds->N[ds->u] = rpmstrPoolId(ds->pool, rpmdsN(ods), 1); - /* XXX rpm prior to 3.0.2 did not always supply EVR and Flags. */ -assert(ods->EVR != NULL); -assert(ods->Flags != NULL); - ds->EVR = xrealloc(ds->EVR, (ds->Count+1) * sizeof(*ds->EVR)); if (ds->u < ds->Count) { memmove(ds->EVR + ds->u + 1, ds->EVR + ds->u, (ds->Count - ds->u) * sizeof(*ds->EVR)); } - ds->EVR[ds->u] = rpmstrPoolId(ds->pool, rpmdsEVR(ods), 1); + OEVR = rpmdsEVR(ods); + ds->EVR[ds->u] = rpmstrPoolId(ds->pool, OEVR ? OEVR : "", 1); ds->Flags = xrealloc(ds->Flags, (ds->Count+1) * sizeof(*ds->Flags)); if (ds->u < ds->Count) { |