From 7b432df61d9abfdca8422399e4714e046efbfd86 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 9 Dec 2022 16:20:09 +0100 Subject: [PATCH] fixed possible memory problems in decrypter --- src/core/lib/decrypter.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/core/lib/decrypter.c b/src/core/lib/decrypter.c index 9f8f16f..c3ea320 100644 --- a/src/core/lib/decrypter.c +++ b/src/core/lib/decrypter.c @@ -60,7 +60,7 @@ outputFlags decryptText(char *text, char *keyNew) //VARIABLES char *returningText; int numberBuffer = 1; - char *textBuffer; + char *textBuffer = malloc(1); int textKeyChainLength; int *textKeyChain; char *key = malloc(strlen(keyNew) + 1); @@ -102,13 +102,7 @@ outputFlags decryptText(char *text, char *keyNew) numberBuffer++; } - if (i != 0) - { - textBuffer = realloc(textBuffer, numberBuffer + 1); - } else - { - textBuffer = malloc(numberBuffer + 1); - } + textBuffer = realloc(textBuffer, numberBuffer + 1); //CLEAN (POSSIBLY EXISTING) JUNK in textBuffer for (int j = 0; j <= numberBuffer; j++)