aboutsummaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
authorweiyanhua <weiyanhua@kuaishou.com>2019-06-13 15:05:22 +0800
committerweiyanhua <weiyanhua@kuaishou.com>2019-06-13 15:05:22 +0800
commite814cd0b9e002e24b25c1990967ab7bc65c64838 (patch)
treeb7e1ada711294716810886e33117bf57fcac3c09 /example
parent709a87c8d442c40aa9f32e450d8e7665732dd9c3 (diff)
add null process for malloc.
Diffstat (limited to 'example')
-rw-r--r--example/ndpi_util.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/example/ndpi_util.c b/example/ndpi_util.c
index 4b8ffb894..8bf440b59 100644
--- a/example/ndpi_util.c
+++ b/example/ndpi_util.c
@@ -178,18 +178,21 @@ struct ndpi_workflow* ndpi_workflow_init(const struct ndpi_workflow_prefs * pref
set_ndpi_flow_malloc(NULL), set_ndpi_flow_free(NULL);
/* TODO: just needed here to init ndpi malloc wrapper */
struct ndpi_detection_module_struct * module = ndpi_init_detection_module();
+ if (module == NULL) {
+ NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
+ exit(-1);
+ }
struct ndpi_workflow * workflow = ndpi_calloc(1, sizeof(struct ndpi_workflow));
-
+ if (workflow == NULL) {
+ NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
+ ndpi_free(module);
+ exit(-1);
+ }
workflow->pcap_handle = pcap_handle;
workflow->prefs = *prefs;
workflow->ndpi_struct = module;
- if(workflow->ndpi_struct == NULL) {
- NDPI_LOG(0, NULL, NDPI_LOG_ERROR, "global structure initialization failed\n");
- exit(-1);
- }
-
ndpi_set_log_level(module, nDPI_LogLevel);
if(_debug_protocols != NULL && ! _debug_protocols_ok) {