Reputation: 215
My simplified code looks like something below:
char decrypted[64] = "P@ssw0rd ";
int realsize = 8;
realloc(decrypted, realsize);
char *dec2 = (char *) malloc(realsize+1); // Exe crashes at this point
I am guessing it has to do with char *dec2 , but this only crashes Win XP for some reason.
Upvotes: 0
Views: 194
Reputation: 16318
decrypted
is an array allocated on the stack. realloc
can only re-allocate memory allocated on the heap with malloc
or calloc
.
Upvotes: 2
Reputation: 62048
You cannot realloc()
what hasn't been allocated with malloc()
or calloc()
or realloc()
.
Upvotes: 7