Changeset: 7f47a148fd51 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7f47a148fd51
Modified Files:
        gdk/gdk_utils.c
Branch: Jul2017
Log Message:

Stop allocating memory with GDKmalloc/realloc when GDK_vm_maxsize is reached.
Just like we already stop with GDKmmap/mremap.


diffs (26 lines):

diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1579,6 +1579,10 @@ GDKmalloc_internal(size_t size)
                return NULL;
        }
 #endif
+       if (GDKvm_cursize() + size >= GDK_vm_maxsize) {
+               GDKerror("allocating too much memory\n");
+               return NULL;
+       }
 
        /* pad to multiple of eight bytes and add some extra space to
         * write real size in front; when debugging, also allocate
@@ -1716,6 +1720,11 @@ GDKrealloc(void *s, size_t size)
        nsize = (size + 7) & ~7;
        asize = ((size_t *) s)[-1]; /* how much allocated last */
 
+       if (nsize > asize &&
+           GDKvm_cursize() + nsize - asize >= GDK_vm_maxsize) {
+               GDKerror("allocating too much memory\n");
+               return NULL;
+       }
 #ifndef NDEBUG
        assert((asize & 2) == 0);   /* check against duplicate free */
        /* check for out-of-bounds writes */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to