summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2014-08-22 11:50:25 +0200
committerPanu Matilainen <pmatilai@redhat.com>2014-08-26 12:49:19 +0300
commitd872a53b0485a57df2913579c263ed9100d7ca6a (patch)
treec07bb684ff78b05597ee46fdd2d481de903f2fd2
parent8ea944ca501612c5643c2997f496494c72aca3e7 (diff)
downloadrpm-d872a53b0485a57df2913579c263ed9100d7ca6a.tar.gz
Fix triggerindex handling in rpmdsMerge
It always created a triggerindex array and also did not correctly initialize it with -1. (cherry picked from commit 1f22cc40518b3f671201803c5f937fae6b6afe63)
-rw-r--r--lib/rpmds.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index e1a6315ee..49e33bc07 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -817,6 +817,12 @@ int rpmdsMerge(rpmds * dsp, rpmds ods)
ds->EVR = xcalloc(ds->Count, sizeof(*ds->EVR));
if (ds->Flags == NULL)
ds->Flags = xcalloc(ds->Count, sizeof(*ds->Flags));
+ if (ds->ti == NULL && ods->ti) {
+ int i;
+ ds->ti = xcalloc(ds->Count, sizeof(*ds->ti));
+ for (i = 0; i < ds->Count; i++)
+ ds->ti[i] = -1;
+ }
/*
* Add new entries.
@@ -858,12 +864,14 @@ int rpmdsMerge(rpmds * dsp, rpmds ods)
}
ds->Flags[u] = rpmdsFlags(ods);
- ds->ti = xrealloc(ds->ti, (ds->Count+1) * sizeof(*ds->ti));
- if (u < ds->Count) {
- memmove(ds->ti + u + 1, ds->ti + u,
- (ds->Count - u) * sizeof(*ds->ti));
+ if (ds->ti || ods->ti) {
+ ds->ti = xrealloc(ds->ti, (ds->Count+1) * sizeof(*ds->ti));
+ if (u < ds->Count) {
+ memmove(ds->ti + u + 1, ds->ti + u,
+ (ds->Count - u) * sizeof(*ds->ti));
+ }
+ ds->ti[u] = rpmdsTi(ods);
}
- ds->ti[u] = rpmdsTi(ods);
ds->i = ds->Count;
ds->Count++;