From b81ef55c86817a4ccf18086fd9b7dc3ee49ae415 Mon Sep 17 00:00:00 2001 From: mpi Date: Wed, 1 Sep 2021 08:06:49 +0000 Subject: [PATCH] Imitate how free(3) behaves and make map_clear() works on NULL map. --- usr.sbin/btrace/map.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.20.1