nitvm: fix a crash caused by a bad allocation of virtual tables
authorJulien Pagès <julien.projet@gmail.com>
Fri, 18 Jul 2014 14:24:23 +0000 (16:24 +0200)
committerJulien Pagès <julien.projet@gmail.com>
Fri, 18 Jul 2014 17:48:51 +0000 (19:48 +0200)
Signed-off-by: Julien Pagès <julien.projet@gmail.com>

src/vm.nit

index eed0d47..0cb7961 100644 (file)
@@ -405,8 +405,9 @@ class MemoryManager
                        total_size += 2;
                }
 
-               // Add the size of the perfect hashtable
-               total_size += mask+1;
+               // Add the size of the perfect hashtable (mask +1)
+               // Add one because we start to fill the vtable at position 1 (0 is the init position)
+               total_size += mask+2;
                long unsigned int* vtable = malloc(sizeof(long unsigned int)*total_size);
                
                // Initialisation to the first position of the virtual table (ie : Object)