fixed invalid allocations
I forgot to add sizeof(int)
This commit is contained in:
parent
625db994c7
commit
67380f51cf
@ -33,9 +33,9 @@ outputFlags decryptText(char *text, char *key, inputFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//SET LENGTH (numberBuffer)
|
//SET LENGTH (numberBuffer)
|
||||||
returningText = malloc(numberBuffer);
|
returningText = malloc(sizeof(int) * numberBuffer);
|
||||||
textKeyChain = malloc(numberBuffer * sizeof(int));
|
textKeyChain = malloc(sizeof(int) * numberBuffer);
|
||||||
int encryptedTextKeyChain[numberBuffer];
|
int encryptedTextKeyChain[sizeof(int) * numberBuffer];
|
||||||
textKeyChainLength = numberBuffer;
|
textKeyChainLength = numberBuffer;
|
||||||
|
|
||||||
//LOAD textKeyChain
|
//LOAD textKeyChain
|
||||||
@ -54,7 +54,7 @@ outputFlags decryptText(char *text, char *key, inputFlags flags)
|
|||||||
numberBuffer++;
|
numberBuffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
textBuffer = malloc(numberBuffer);
|
textBuffer = malloc(sizeof(int) * numberBuffer);
|
||||||
|
|
||||||
//LOAD textBuffer
|
//LOAD textBuffer
|
||||||
for (int j = 0; j < strlen(text); j++)
|
for (int j = 0; j < strlen(text); j++)
|
||||||
|
@ -17,10 +17,10 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
srand(time(0)); //TRY TO MAKE RANDOM GENERATION REALLY "RANDOM"
|
srand(time(0)); //TRY TO MAKE RANDOM GENERATION REALLY "RANDOM"
|
||||||
|
|
||||||
//VARIABLES
|
//VARIABLES
|
||||||
char *key = malloc(getKeyLength());
|
char *key = malloc(sizeof(int) * getKeyLength());
|
||||||
char *returningText;
|
char *returningText;
|
||||||
char *textBuffer;
|
char *textBuffer;
|
||||||
int *textKeyChain = malloc(strlen(text) * sizeof(int));
|
int *textKeyChain = malloc(sizeof(int) * strlen(text));
|
||||||
int numberBuffer = 0;
|
int numberBuffer = 0;
|
||||||
|
|
||||||
if (keyNew != NULL)
|
if (keyNew != NULL)
|
||||||
@ -75,13 +75,13 @@ outputFlags encryptText(char *text, char *keyNew, inputFlags flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//ALLOCATE returningText (WITH THE SEPARATORS)
|
//ALLOCATE returningText (WITH THE SEPARATORS)
|
||||||
returningText = malloc(numberBuffer + strlen(text) - 1);
|
returningText = malloc(sizeof(int) * numberBuffer + strlen(text) - 1);
|
||||||
strcpy(returningText, "");
|
strcpy(returningText, "");
|
||||||
|
|
||||||
//LOAD returningText
|
//LOAD returningText
|
||||||
for (int i = 0; i < strlen(text); i++)
|
for (int i = 0; i < strlen(text); i++)
|
||||||
{
|
{
|
||||||
textBuffer = malloc(countIntLength(textKeyChain[i]));
|
textBuffer = malloc(sizeof(int) * countIntLength(textKeyChain[i]));
|
||||||
|
|
||||||
sprintf(textBuffer, "%d", textKeyChain[i]);
|
sprintf(textBuffer, "%d", textKeyChain[i]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user