Skip to content

Commit

Permalink
Fix: possible memory leak detected via ccc-analyzer
Browse files Browse the repository at this point in the history
Move memory allocation inside 'if' block and avoid memory leak

Bug Summary
File:	nasl/nasl_crypto2.c
Warning:	line 1919, column 3
Potential leak of memory pointed to by 'auth'
  • Loading branch information
jjnicola committed Oct 21, 2022
1 parent 6073025 commit e3fef97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions nasl/nasl_crypto2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1885,10 +1885,12 @@ crypt_data (lex_ctxt *lexic, int cipher, int mode, int flags)
return NULL;
}
}
authlen = 16;
auth = g_malloc0 (authlen);

if (flags & NASL_AAD)
{
authlen = 16;
auth = g_malloc0 (authlen);

if ((error = gcry_cipher_gettag (hd, auth, authlen)))
{
g_message ("gcry_cipher_gettag: %s", gcry_strerror (error));
Expand Down

0 comments on commit e3fef97

Please sign in to comment.