Skip to content

Commit 784e38c

Browse files
committed
lib: add oom handling to xbps_pkgdb_foreach_cb_multi
1 parent 06f92b1 commit 784e38c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

lib/pkgdb.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -398,16 +398,17 @@ xbps_pkgdb_foreach_cb_multi(struct xbps_handle *xhp,
398398
void *arg)
399399
{
400400
xbps_array_t allkeys;
401-
int rv;
401+
int r;
402402

403-
if ((rv = xbps_pkgdb_init(xhp)) != 0)
404-
return rv;
403+
assert(xhp->pkgdb);
405404

406405
allkeys = xbps_dictionary_all_keys(xhp->pkgdb);
407-
assert(allkeys);
408-
rv = xbps_array_foreach_cb_multi(xhp, allkeys, xhp->pkgdb, fn, arg);
406+
if (!allkeys)
407+
return xbps_error_oom();
408+
409+
r = xbps_array_foreach_cb_multi(xhp, allkeys, xhp->pkgdb, fn, arg);
409410
xbps_object_release(allkeys);
410-
return rv;
411+
return r;
411412
}
412413

413414
xbps_dictionary_t

0 commit comments

Comments
 (0)