diff --git a/historic/jam/src/newstr.c b/historic/jam/src/newstr.c index 32562d4a9..58668fcb6 100644 --- a/historic/jam/src/newstr.c +++ b/historic/jam/src/newstr.c @@ -74,7 +74,7 @@ static char* allocate(size_t n) nalloc = STRING_BLOCK; /* allocate a new block and link into the chain */ - new_block = malloc( offsetof( strblock, data[nalloc] ) ); + new_block = malloc( offsetof( strblock, data[0] ) + nalloc * sizeof(new_block->data[0]) ); if ( new_block == 0 ) return 0; new_block->next = strblock_chain; diff --git a/jam_src/newstr.c b/jam_src/newstr.c index 32562d4a9..58668fcb6 100644 --- a/jam_src/newstr.c +++ b/jam_src/newstr.c @@ -74,7 +74,7 @@ static char* allocate(size_t n) nalloc = STRING_BLOCK; /* allocate a new block and link into the chain */ - new_block = malloc( offsetof( strblock, data[nalloc] ) ); + new_block = malloc( offsetof( strblock, data[0] ) + nalloc * sizeof(new_block->data[0]) ); if ( new_block == 0 ) return 0; new_block->next = strblock_chain;