Fixed a segfault when the system can initialise no more pages.

Still not fixed the `member?` bug.
This commit is contained in:
Simon Brooke 2026-03-18 13:27:19 +00:00
parent 69b199fecd
commit 7d0ce67373
3 changed files with 25 additions and 19 deletions

View file

@ -65,7 +65,11 @@ struct cons_page *conspages[NCONSPAGES];
* that exception would have to have been pre-built.
*/
void make_cons_page( ) {
struct cons_page *result = malloc( sizeof( struct cons_page ) );
struct cons_page *result = NULL;
if ( initialised_cons_pages < NCONSPAGES) {
result = malloc( sizeof( struct cons_page ) );
}
if ( result != NULL ) {
conspages[initialised_cons_pages] = result;
@ -116,12 +120,10 @@ void make_cons_page( ) {
initialised_cons_pages++;
} else {
debug_printf( DEBUG_ALLOC,
L"FATAL: Failed to allocate memory for cons page %d\n",
initialised_cons_pages );
fwide( stderr, 1 );
fwprintf( stderr, L"FATAL: Failed to allocate memory for cons page %d\n", initialised_cons_pages );
exit( 1 );
}
}
/**