[Rpm-maint] [rpm-software-management/rpm] rpmidxGetInternal(): leak on realloc() failure (#357)

Alan Jenkins notifications at github.com
Mon Nov 13 13:07:30 UTC 2017


When realloc() fails the original allocation remains, and should be freed at some point.

Can rpmidxGetInternal() be converted to xrealloc() ?  I'm unsure because there might be a deliberate reason, e.g. why we still have 130 references directly to malloc() and not xmalloc().

```
@@ -927,16 +927,14 @@ static int rpmidxGetInternal(rpmidxdb idxdb, const unsigned char *key, unsigned
 	}
 	if (keyoff != x)
 	    continue;
 	if ((nhits & 15) == 0) {
 	    if (!hits) {
-		hits = malloc(16 * sizeof(unsigned int));
+		hits = xmalloc(16 * sizeof(unsigned int));
 	    } else {
-		hits = realloc(hits, (nhits + 16) * sizeof(unsigned int));
+		hits = xrealloc(hits, (nhits + 16) * sizeof(unsigned int));
 	    }
-	    if (!hits)
-		return RPMRC_FAIL;
 	}
 	data = le2ha(ent + 4);
 	ovldata = (data & 0x80000000) ? le2ha(idxdb->slot_mapped + idxdb->nslots * 8 + 4 * h) : 0;
 	hits[nhits++] = decodedata(idxdb, data, ovldata, &datidx);
 	hits[nhits++] = datidx;
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/issues/357
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20171113/f7e54de1/attachment.html>


More information about the Rpm-maint mailing list