Skip to content

Commit

Permalink
Fix: possible memory leak detected via ccc-analyzer
Browse files Browse the repository at this point in the history
Allocate memory later and fix possible memory leak

Bug Summary
File:	nasl/nasl_snmp.c
Warning:	line 745, column 7
Potential leak of memory pointed to by 'result'
  • Loading branch information
jjnicola committed Oct 21, 2022
1 parent 7a312d8 commit f9298a0
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nasl/nasl_snmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,6 @@ nasl_snmpv3_get_action (lex_ctxt *lexic, u_char action)
char *oid_str;
static char *next_oid_str;

result = g_malloc0 (sizeof (struct snmp_result));
request = g_malloc0 (sizeof (struct snmpv3_request));

request->action = action;
Expand Down Expand Up @@ -782,6 +781,8 @@ nasl_snmpv3_get_action (lex_ctxt *lexic, u_char action)
g_snprintf (peername, sizeof (peername), "%s:%s:%d", proto,
plug_get_host_ip_str (lexic->script_infos), port);
request->peername = peername;

result = g_malloc0 (sizeof (struct snmp_result));
ret = snmpv3_get (request, result);

// Hack the OID string to adjust format. Replace 'iso.' with '.1.'
Expand Down

0 comments on commit f9298a0

Please sign in to comment.