fixed (I hope) every allocation size
"Just use Valgrind", they said.... I should listen to them
This commit is contained in:
parent
62b2094d48
commit
4aa80c199c
@ -45,7 +45,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
char *textBuffer;
|
char *textBuffer;
|
||||||
int textKeyChainLength;
|
int textKeyChainLength;
|
||||||
int *textKeyChain;
|
int *textKeyChain;
|
||||||
char *key = malloc(strlen(keyNew));
|
char *key = malloc(strlen(keyNew) + 1);
|
||||||
|
|
||||||
//COPY keyNew TO key
|
//COPY keyNew TO key
|
||||||
strcpy(key, keyNew);
|
strcpy(key, keyNew);
|
||||||
@ -57,7 +57,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//SET LENGTH (numberBuffer)
|
//SET LENGTH (numberBuffer)
|
||||||
returningText = malloc(numberBuffer);
|
returningText = malloc(numberBuffer + 1);
|
||||||
textKeyChain = malloc(sizeof(int) * numberBuffer);
|
textKeyChain = malloc(sizeof(int) * numberBuffer);
|
||||||
int encryptedTextKeyChain[sizeof(int) * numberBuffer];
|
int encryptedTextKeyChain[sizeof(int) * numberBuffer];
|
||||||
textKeyChainLength = numberBuffer;
|
textKeyChainLength = numberBuffer;
|
||||||
@ -78,7 +78,7 @@ outputFlags decryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
numberBuffer++;
|
numberBuffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
textBuffer = malloc(numberBuffer);
|
textBuffer = malloc(numberBuffer + 1);
|
||||||
|
|
||||||
//LOAD textBuffer
|
//LOAD textBuffer
|
||||||
for (int j = 0; j < strlen(text); j++)
|
for (int j = 0; j < strlen(text); j++)
|
||||||
|
@ -33,7 +33,7 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
char *key = malloc(getKeyLength());
|
char *key = malloc(getKeyLength() + 1);
|
||||||
char *returningText;
|
char *returningText;
|
||||||
char *textBuffer;
|
char *textBuffer;
|
||||||
int *textKeyChain = malloc(sizeof(int) * strlen(text));
|
int *textKeyChain = malloc(sizeof(int) * strlen(text));
|
||||||
|
@ -118,7 +118,7 @@ unsigned char checkVersion(inputFlags flags)
|
|||||||
rewind(fileBuffer); //REWIND fileBuffer (NO SHIT)
|
rewind(fileBuffer); //REWIND fileBuffer (NO SHIT)
|
||||||
|
|
||||||
//SET LENGTH OF buffer
|
//SET LENGTH OF buffer
|
||||||
buffer = malloc(bufferSize);
|
buffer = malloc(bufferSize + 1);
|
||||||
|
|
||||||
//FIX buffer
|
//FIX buffer
|
||||||
strcpy(buffer, "");
|
strcpy(buffer, "");
|
||||||
|
@ -22,7 +22,7 @@ int main(void)
|
|||||||
|
|
||||||
//SET KEY_LENGTH TO 100
|
//SET KEY_LENGTH TO 100
|
||||||
setKeyLength(100);
|
setKeyLength(100);
|
||||||
keyBuffer = malloc(getKeyLength());
|
keyBuffer = malloc(getKeyLength() + 1);
|
||||||
|
|
||||||
//ENCRYPT
|
//ENCRYPT
|
||||||
outputFlags encrypted = encryptText(TEST_TEXT, NULL, flags);
|
outputFlags encrypted = encryptText(TEST_TEXT, NULL, flags);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user