--- ffi.c.orig 2015-04-04 15:43:19.662709073 -0700 +++ ffi.c 2015-04-04 15:51:27.142665269 -0700 @@ -629,12 +629,21 @@ /* We have valid trampoline and config pages */ table = calloc (1, sizeof(ffi_trampoline_table)); + if (table == NULL) { /* oops, calloc() failed, now what??? */ + fprintf(stderr, "vm calloc() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); + return NULL; /* go home??? */ + } table->free_count = FFI_TRAMPOLINE_COUNT; table->config_page = config_page; table->trampoline_page = trampoline_page; /* Create and initialize the free list */ table->free_list_pool = calloc(FFI_TRAMPOLINE_COUNT, sizeof(ffi_trampoline_table_entry)); + if (table->free_list_pool == NULL) { /* oops, calloc() failed, now what */ + fprintf(stderr, "vm calloc() failure: %d at %s:%d\n", kt, __FILE__, __LINE__); + free(table); /* free table (from previos calloc() call) */ + return NULL; /* go home??? * + } uint16_t i; for (i = 0; i < table->free_count; i++) {