fixed possible memory problems in decrypter

This commit is contained in:
Václav Šmejkal 2022-12-09 16:20:09 +01:00
parent a1852354b4
commit 7b432df61d
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19

View File

@ -60,7 +60,7 @@ outputFlags decryptText(char *text, char *keyNew)
//VARIABLES //VARIABLES
char *returningText; char *returningText;
int numberBuffer = 1; int numberBuffer = 1;
char *textBuffer; char *textBuffer = malloc(1);
int textKeyChainLength; int textKeyChainLength;
int *textKeyChain; int *textKeyChain;
char *key = malloc(strlen(keyNew) + 1); char *key = malloc(strlen(keyNew) + 1);
@ -102,13 +102,7 @@ outputFlags decryptText(char *text, char *keyNew)
numberBuffer++; numberBuffer++;
} }
if (i != 0)
{
textBuffer = realloc(textBuffer, numberBuffer + 1); textBuffer = realloc(textBuffer, numberBuffer + 1);
} else
{
textBuffer = malloc(numberBuffer + 1);
}
//CLEAN (POSSIBLY EXISTING) JUNK in textBuffer //CLEAN (POSSIBLY EXISTING) JUNK in textBuffer
for (int j = 0; j <= numberBuffer; j++) for (int j = 0; j <= numberBuffer; j++)