Fixup same manner to previous svace patch
authorSung-jae Park <nicesj.park@samsung.com>
Fri, 17 Sep 2021 04:44:29 +0000 (13:44 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Wed, 22 Sep 2021 22:46:13 +0000 (07:46 +0900)
[Problem] There was a svace alert for the resource leak
[Solution] Fixup like what the previous patch did

 * This and previous patch is not possible to happen
   However, for the safe-coding, applies this patch too

Change-Id: I44d86a280d184287f6025e763b8d2d2a55cedcdf
Signed-off-by: Sung-jae Park <nicesj.park@samsung.com>
subprojects/libbeyond-authenticator_ssl/src/authenticator.cc

index be09c38..dad0dae 100644 (file)
@@ -1062,8 +1062,8 @@ int Authenticator::Crypto(int opid, beyond_authenticator_key_id id, const void *
         }
 
         if (opid == CRYPTO_OP::ENCRYPT && sslConfig.enableBase64 == true) {
-            char *_output;
-            int _outputSize;
+            char *_output = nullptr;
+            int _outputSize = 0;
             ret = EncodeBase64(_output, _outputSize, static_cast<unsigned char *>(out), outlen);
             free(out);
             out = nullptr;
@@ -1074,6 +1074,7 @@ int Authenticator::Crypto(int opid, beyond_authenticator_key_id id, const void *
                 break;
             } else if (_output == nullptr || _outputSize <= 0) {
                 ErrPrint("Invalid encoded data");
+                free(_output);
                 delete output;
                 output = nullptr;
                 ret = -EINVAL;