Skip to content

Instantly share code, notes, and snippets.

@Beyarz
Last active October 9, 2019 15:26
Show Gist options
  • Save Beyarz/b243c06fe0040373cbe85e0c62922e5a to your computer and use it in GitHub Desktop.
Save Beyarz/b243c06fe0040373cbe85e0c62922e5a to your computer and use it in GitHub Desktop.
When allocating memory using malloc, malloc sends the enomem error if the amount of memory requested exceeds the _heap_maxreq. This script bypasses that.
// Working on Windows 10 Insider Preview 18356.1 (19h1_release)
#include <stdio.h>
#include <stdlib.h>
#define byte sizeof(int)
int main(){
char *ptr;
puts("Allocating...");
for(int z = 0; z != -1; z++){
ptr = (char *)malloc(byte);
if(ptr == NULL){
puts("Failed to allocate!");
return 1;
}
}
// free(ptr); - not useful if it's running infinitely.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment