fixed (I hope) every allocation size

"Just use Valgrind", they said.... I should listen to them
This commit is contained in:
Václav Šmejkal 2022-06-13 18:13:27 +02:00
parent 62b2094d48
commit 4aa80c199c
No known key found for this signature in database
GPG Key ID: FD749A97DF2D5E19
4 changed files with 6 additions and 6 deletions

@ -45,7 +45,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
char *textBuffer;
int textKeyChainLength;
int *textKeyChain;
char *key = malloc(strlen(keyNew));
char *key = malloc(strlen(keyNew) + 1);
//COPY keyNew TO key
strcpy(key, keyNew);
@ -57,7 +57,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
}
//SET LENGTH (numberBuffer)
returningText = malloc(numberBuffer);
returningText = malloc(numberBuffer + 1);
textKeyChain = malloc(sizeof(int) * numberBuffer);
int encryptedTextKeyChain[sizeof(int) * numberBuffer];
textKeyChainLength = numberBuffer;
@ -78,7 +78,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
numberBuffer++;
}
textBuffer = malloc(numberBuffer);
textBuffer = malloc(numberBuffer + 1);
//LOAD textBuffer
for (int j = 0; j < strlen(text); j++)

@ -33,7 +33,7 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
}
//VARIABLES
char *key = malloc(getKeyLength());
char *key = malloc(getKeyLength() + 1);
char *returningText;
char *textBuffer;
int *textKeyChain = malloc(sizeof(int) * strlen(text));

@ -118,7 +118,7 @@ unsigned char checkVersion(inputFlags flags)
rewind(fileBuffer); //REWIND fileBuffer (NO SHIT)
//SET LENGTH OF buffer
buffer = malloc(bufferSize);
buffer = malloc(bufferSize + 1);
//FIX buffer
strcpy(buffer, "");

@ -22,7 +22,7 @@ int main(void)
//SET KEY_LENGTH TO 100
setKeyLength(100);
keyBuffer = malloc(getKeyLength());
keyBuffer = malloc(getKeyLength() + 1);
//ENCRYPT
outputFlags encrypted = encryptText(TEST_TEXT, NULL, flags);