diff options
author | Endi S. Dewata <edewata@redhat.com> | 2010-07-02 00:27:43 -0500 |
---|---|---|
committer | Noriko Hosoi <nhosoi@redhat.com> | 2010-08-23 11:07:22 -0700 |
commit | 2ff2c9da762d67628cf25a1ceda3b1dbb9218776 (patch) | |
tree | 80ef54991ee3f3a741e8be366153e9194975b017 /ldap | |
parent | 387ace29a50ac1a4c8c8958c71250b7bb7082ea5 (diff) | |
download | ds-2ff2c9da762d67628cf25a1ceda3b1dbb9218776.tar.gz ds-2ff2c9da762d67628cf25a1ceda3b1dbb9218776.tar.xz ds-2ff2c9da762d67628cf25a1ceda3b1dbb9218776.zip |
Bug 610119 - fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
https://bugzilla.redhat.com/show_bug.cgi?id=610119
Resolves: bug 610119
Bug description: Fix coverify Defect Type: Null pointer dereferences issues 12167 - 12199
Fix description: Catch possible NULL pointer in stats_table_create_row().
Diffstat (limited to 'ldap')
-rw-r--r-- | ldap/servers/snmp/ldap-agent.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/ldap/servers/snmp/ldap-agent.c b/ldap/servers/snmp/ldap-agent.c index c51bfdc0..473a0e5e 100644 --- a/ldap/servers/snmp/ldap-agent.c +++ b/ldap/servers/snmp/ldap-agent.c @@ -227,20 +227,25 @@ stats_table_create_row(unsigned long portnum) stats_table_context *ctx = SNMP_MALLOC_TYPEDEF(stats_table_context); oid *index_oid = (oid *)malloc(sizeof(oid) * MAX_OID_LEN); + if (!ctx || !index_oid) { + /* Error during malloc */ + snmp_log(LOG_ERR, "malloc failed in stats_table_create_row\n"); + goto error; + } + /* Create index using port number */ index_oid[0] = portnum; index.oids = index_oid; index.len = 1; /* Copy index into row structure */ - if (ctx && index_oid) { - memcpy(&ctx->index, &index, sizeof(index)); - return ctx; - } else { - /* Error during malloc */ - snmp_log(LOG_ERR, "malloc failed in stats_table_create_row\n"); - return NULL; - } + memcpy(&ctx->index, &index, sizeof(index)); + return ctx; + +error: + if (index_oid) free(index_oid); + if (ctx) SNMP_FREE(ctx); + return NULL; } /************************************************************ |