Browse code

crypto: use same condition to free ttext.s on success or error

Daniel-Constantin Mierla authored on 06/04/2021 15:54:46
Showing 1 changed files
... ...
@@ -284,16 +284,18 @@ static int ki_crypto_aes_encrypt_helper(sip_msg_t* msg, str *ins, str *keys,
284 284
 	val.flags = PV_VAL_STR;
285 285
 	dst->setf(msg, &dst->pvp, (int)EQ_T, &val);
286 286
 
287
-	free(etext.s);
288
-	if (! _crypto_key_derivation)
287
+	if (ttext.s != etext.s) {
289 288
 		pkg_free(ttext.s);
289
+	}
290
+	free(etext.s);
290 291
 	EVP_CIPHER_CTX_cleanup(en);
291 292
 	EVP_CIPHER_CTX_free(en);
292 293
 	return 1;
293 294
 
294 295
 error:
295
-	if (ttext.s != etext.s)
296
+	if (ttext.s != etext.s) {
296 297
 		pkg_free(ttext.s);
298
+	}
297 299
 error1:
298 300
 	free(etext.s);
299 301
 	EVP_CIPHER_CTX_cleanup(en);