Practice safe free()'ing by setting alloc to NULL to
authorkrw <krw@openbsd.org>
Thu, 30 Aug 2018 13:07:19 +0000 (13:07 +0000)
committerkrw <krw@openbsd.org>
Thu, 30 Aug 2018 13:07:19 +0000 (13:07 +0000)
prevent double free.

Spotted by jsg@, simpler fix by myself and miko@.

ok jsg@

sbin/disklabel/editor.c

index 5412b17..060d80d 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: editor.c,v 1.347 2018/08/30 12:30:08 krw Exp $        */
+/*     $OpenBSD: editor.c,v 1.348 2018/08/30 13:07:19 krw Exp $        */
 
 /*
  * Copyright (c) 1997-2000 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -572,6 +572,7 @@ editor_allocspace(struct disklabel *lp_org)
        index = -1;
 again:
        free(alloc);
+       alloc = NULL;
        index++;
        if (index >= alloc_table_nitems)
                return 1;