Don't mess up problem altNEVR in python ts.check() (rhbz#501068)
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 19 May 2009 07:26:50 +0000 (10:26 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Tue, 19 May 2009 07:29:53 +0000 (10:29 +0300)
- the use of strrchr() silently casts away the const from the problem
  set altNEVR string, which we then happily modify..
- similar to commit 62cc76e25cdfad78ac30bb28f626b474efdecddc
(cherry picked from commit 9322f737819a3d81088699b1d7fa667259245411)

python/rpmts-py.c

index 84da9cb..115cbbe 100644 (file)
@@ -365,7 +365,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
 
        /* XXX TODO: rpmlib >= 4.0.3 can return multiple suggested keys. */
        while ((i = rpmpsNextIterator(psi)) >= 0) {
-           const char * needsName;
+           char * altNEVR, * needsName;
            char * byName, * byVersion, * byRelease, *byArch;
            char * needsOP, * needsVersion;
            rpmsenseFlags needsFlags, sense;
@@ -383,7 +383,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
 
            key = rpmProblemGetKey(p);
 
-           needsName = rpmProblemGetAltNEVR(p);
+           altNEVR = needsName = xstrdup(rpmProblemGetAltNEVR(p));
            if (needsName[1] == ' ') {
                sense = (needsName[0] == 'C')
                        ? RPMDEP_SENSE_CONFLICTS : RPMDEP_SENSE_REQUIRES;
@@ -409,6 +409,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb);
            PyList_Append(list, (PyObject *) cf);
            Py_DECREF(cf);
            free(byName);
+           free(altNEVR);
        }
 
        psi = rpmpsFreeIterator(psi);