Skip to content

Commit d3214b1

Browse files
committed
bin/xbps-pkgdb: handle oom in alternative path creation
1 parent 7885b10 commit d3214b1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

bin/xbps-pkgdb/check_pkg_alternatives.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ relpath(char *from, char *to)
8686
for (up = -1, from--; from && *from; from = strchr(from + 1, '/'), up++);
8787

8888
rel = calloc(1, 3 * up + strlen(p) + 1);
89+
if (!rel)
90+
return NULL;
8991

9092
while (up--)
9193
strcat(rel, "../");
@@ -126,6 +128,8 @@ check_symlinks(struct xbps_handle *xhp, const char *pkgname, xbps_array_t a,
126128

127129
if (target[0] == '/') {
128130
p = relpath(linkpath + strlen(xhp->rootdir), target);
131+
if (!p)
132+
return xbps_error_oom();
129133
free(target);
130134
target = p;
131135
}

0 commit comments

Comments
 (0)