replaced repeating malloc with realloc
tf I tried to fix this much earlier but it was throwing segfaults... I should start taking those pills
This commit is contained in:
parent
090d82842c
commit
dfbf65cc0f
@ -79,7 +79,13 @@ outputFlags decryptText(char *text, char *keyNew)
|
|||||||
numberBuffer++;
|
numberBuffer++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i != 0)
|
||||||
|
{
|
||||||
|
textBuffer = realloc(textBuffer, numberBuffer + 1);
|
||||||
|
} else
|
||||||
|
{
|
||||||
textBuffer = malloc(numberBuffer + 1);
|
textBuffer = malloc(numberBuffer + 1);
|
||||||
|
}
|
||||||
|
|
||||||
//LOAD textBuffer
|
//LOAD textBuffer
|
||||||
for (int j = 0; j < (int) strlen(text); j++)
|
for (int j = 0; j < (int) strlen(text); j++)
|
||||||
@ -92,7 +98,6 @@ outputFlags decryptText(char *text, char *keyNew)
|
|||||||
encryptedTextKeyChain[i] = atoi(textBuffer);
|
encryptedTextKeyChain[i] = atoi(textBuffer);
|
||||||
|
|
||||||
text += numberBuffer + 1;
|
text += numberBuffer + 1;
|
||||||
free(textBuffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//DECRYPT TEXT
|
//DECRYPT TEXT
|
||||||
@ -130,6 +135,7 @@ outputFlags decryptText(char *text, char *keyNew)
|
|||||||
//DEALLOCATION
|
//DEALLOCATION
|
||||||
free(textKeyChain);
|
free(textKeyChain);
|
||||||
free(encryptedTextKeyChain);
|
free(encryptedTextKeyChain);
|
||||||
|
free(textBuffer);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user