From: mpi Date: Wed, 1 Sep 2021 08:06:49 +0000 (+0000) Subject: Imitate how free(3) behaves and make map_clear() works on NULL map. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=b81ef55c86817a4ccf18086fd9b7dc3ee49ae415;p=openbsd Imitate how free(3) behaves and make map_clear() works on NULL map. --- diff --git a/usr.sbin/btrace/map.c b/usr.sbin/btrace/map.c index b5bb8fb76ef..5624db68069 100644 --- a/usr.sbin/btrace/map.c +++ b/usr.sbin/btrace/map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: map.c,v 1.15 2021/09/01 07:35:21 mpi Exp $ */ +/* $OpenBSD: map.c,v 1.16 2021/09/01 08:06:49 mpi Exp $ */ /* * Copyright (c) 2020 Martin Pieuchot @@ -84,6 +84,9 @@ map_clear(struct map *map) { struct mentry *mep; + if (map == NULL) + return; + while ((mep = RB_MIN(map, map)) != NULL) { RB_REMOVE(map, map, mep); free(mep);