diff options
author | Luca Deri <lucaderi@users.noreply.github.com> | 2019-06-22 15:40:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-22 15:40:25 +0200 |
commit | c4f513f6e7c93edc6171e69852935098dc571bb8 (patch) | |
tree | 6c946ad21d31aec1a905a1d4e4f93a9ec037fa15 /example | |
parent | 4ea8eaf1033e80ff89ae567f710eb931b7d382ef (diff) | |
parent | e814cd0b9e002e24b25c1990967ab7bc65c64838 (diff) |
Merge pull request #717 from weiyanhua100/dev
add null process for malloc.
Diffstat (limited to 'example')
-rw-r--r-- | example/ndpi_util.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/example/ndpi_util.c b/example/ndpi_util.c index e453a3461..328047b90 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) { |