Handle the case in freechunks where not a single allocation has happened.
authorotto <otto@openbsd.org>
Sun, 13 Feb 2022 20:02:30 +0000 (20:02 +0000)
committerotto <otto@openbsd.org>
Sun, 13 Feb 2022 20:02:30 +0000 (20:02 +0000)
ok deraadt@

lib/libpcap/gencode.c

index 1a64216..d15f174 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gencode.c,v 1.59 2021/12/05 16:40:24 deraadt Exp $    */
+/*     $OpenBSD: gencode.c,v 1.60 2022/02/13 20:02:30 otto Exp $       */
 
 /*
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998
@@ -205,6 +205,8 @@ freechunks(void)
        int i, j;
 
        for (i = 0; i <= cur_membag; i++) {
+               if (membag[i].ptrs == NULL)
+                       continue;
                for (j = 0; j <= membag[i].slot; j++)
                        free(membag[i].ptrs[j]);
                free(membag[i].ptrs);