lib/package_alternatives.c: fix CID 284970 (Resource leak).

Also fix calloc args order.
This commit is contained in:
Juan RP 2020-04-19 11:38:09 +02:00
parent c5904cc6ef
commit 7b623783c8
No known key found for this signature in database
GPG Key ID: AF19F6CB482F9368

View File

@ -98,7 +98,9 @@ relpath(char *from, char *to)
for (up = -1, from--; from && *from; from = strchr(from + 1, '/'), up++);
rel = calloc(3 * up + strlen(p), sizeof(char));
rel = calloc(1, 3 * up + strlen(p));
if (!rel)
return NULL;
while (up--)
strcat(rel, "../");