Loading...
src/dyldNew.cpp dyld-625.13 dyld-421.1
--- dyld/dyld-625.13/src/dyldNew.cpp
+++ dyld/dyld-421.1/src/dyldNew.cpp
@@ -69,8 +69,8 @@
 	}
 	else {
 		if ( size > DYLD_POOL_CHUNK_SIZE ) {
-			dyld::log("dyld malloc overflow: size=%lu\n", size);
-			dyld::halt("dyld malloc overflow\n");
+			dyld::log("dyld malloc overflow: size=%zu\n", size);
+			exit(1);
 		}
 		size = (size+sizeof(void*)-1) & (-sizeof(void*)); // pointer align
 		uint8_t* result = currentPool->current;
@@ -79,7 +79,8 @@
 			vm_address_t addr = 0;
 			kern_return_t r = vm_allocate(mach_task_self(), &addr, DYLD_POOL_CHUNK_SIZE, VM_FLAGS_ANYWHERE);
 			if ( r != KERN_SUCCESS ) {
-				dyld::halt("out of address space for dyld memory pool\n");
+				dyld::log("out of address space for dyld memory pool\n");
+				exit(1);
 			}
 			dyld_static_pool* newPool = (dyld_static_pool*)addr;
 			newPool->previousPool = NULL;
@@ -89,7 +90,7 @@
 			currentPool = newPool;
 			if ( (currentPool->current + size) > currentPool->end ) {
 				dyld::log("dyld memory pool exhausted: size=%lu\n", size);
-				dyld::halt("dyld memory pool exhausted\n");
+				exit(1);
 			}
 			result = currentPool->current;
 			currentPool->current += size;
@@ -125,20 +126,18 @@
 
 void* calloc(size_t count, size_t size)
 {
-    // Check for overflow of integer multiplication
-    size_t total = count * size;
-    if ( total/count != size ) {
-        dyld::log("dyld calloc overflow: count=%zu, size=%zu\n", count, size);
-        dyld::halt("dyld calloc overflow");
-    }
 	if ( dyld::gLibSystemHelpers != NULL ) {
-		void* result = dyld::gLibSystemHelpers->malloc(total);
-        if ( result != NULL )
-		    bzero(result, total);
+		void* result = dyld::gLibSystemHelpers->malloc(size*count);
+		bzero(result, size*count);
 		return result;
 	}
 	else {
-        // this allocates out of static buffer which is already zero filled
+		// Check for overflow of integer multiplication
+		size_t total = count * size;
+		if ( total/count != size ) {
+			dyld::log("dyld calloc overflow: count=%zu, size=%zu\n", count, size);
+			exit(1);
+		}
 		return malloc(total);
 	}
 }