Skip to content

Commit

Permalink
agent: row merges: avoided potential null dereferences
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Korotkov <[email protected]>
  • Loading branch information
ProjectMutilation committed Dec 20, 2023
1 parent 80a1742 commit abb648a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions agent/helpers/row_merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ netsnmp_row_merge_helper_handler(netsnmp_mib_handler *handler,
*/
rm_status = netsnmp_row_merge_status_get(reginfo, reqinfo, 1);

if (!rm_status) {
return SNMP_ERR_GENERR;
}

/*
* Count the requests, and set up an array to keep
* track of the original order.
Expand Down Expand Up @@ -273,6 +277,13 @@ netsnmp_row_merge_helper_handler(netsnmp_mib_handler *handler,
rm_status->saved_status = calloc(count, sizeof(char));
}

if (!rm_status->saved_requests || !rm_status->saved_status) {
free(rm_status->saved_requests);
free(rm_status->saved_status);
free(rm_status);
return SNMP_ERR_GENERR;
}

saved_status = rm_status->saved_status;
saved_requests = rm_status->saved_requests;

Expand Down

0 comments on commit abb648a

Please sign in to comment.