Changeset: 1ba63a58c54c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1ba63a58c54c
Modified Files:
        gdk/gdk_heap.c
Branch: Sep2022
Log Message:

After failed allocation of a heap, make sure the heap file is removed.


diffs (34 lines):

diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -162,20 +162,27 @@ HEAPalloc(Heap *h, size_t nitems, size_t
                h->base = GDKmalloc(h->size);
                TRC_DEBUG(HEAP, "%s %zu %p\n", h->filename, h->size, h->base);
        }
+
+       char *nme = NULL;
        if (!GDKinmemory(h->farmid) && h->base == NULL) {
-               char *nme;
-
                nme = GDKfilepath(h->farmid, BATDIR, h->filename, NULL);
                if (nme == NULL)
                        return GDK_FAIL;
                h->storage = STORE_MMAP;
                h->base = HEAPcreatefile(NOFARM, &h->size, nme);
-               GDKfree(nme);
        }
        if (h->base == NULL) {
+               /* remove file we may just have created */
+               if (nme != NULL) {
+                       /* file may or may not exist, depending on what
+                        * failed */
+                       (void) MT_remove(nme);
+                       GDKfree(nme);
+               }
                GDKerror("Insufficient space for HEAP of %zu bytes.", h->size);
                return GDK_FAIL;
        }
+       GDKfree(nme);
        h->newstorage = h->storage;
        return GDK_SUCCEED;
 }
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to