Prevent Segfault when building with -DNDPI_ENABLE_DEBUG_MESSAGES
This commit is contained in:
@@ -181,13 +181,17 @@
|
||||
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
|
||||
#define NDPI_LOG(proto, mod, log_level, args...) \
|
||||
#define NDPI_LOG(proto, m, log_level, args...) \
|
||||
{ \
|
||||
struct ndpi_detection_module_struct *mod = (struct ndpi_detection_module_struct*) m; \
|
||||
if(mod != NULL) { \
|
||||
mod->ndpi_debug_print_file=__FILE__; \
|
||||
mod->ndpi_debug_print_function=__FUNCTION__; \
|
||||
mod->ndpi_debug_print_line=__LINE__; \
|
||||
mod->ndpi_debug_printf(proto, mod, log_level, args); \
|
||||
if (mod->ndpi_debug_printf != NULL) \
|
||||
mod->ndpi_debug_printf(proto, mod, log_level, args); \
|
||||
else \
|
||||
printf(args, proto, mod, log_level); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
+5
-2
@@ -1716,7 +1716,10 @@ void set_ndpi_free(void (*__ndpi_free)(void *ptr)) { _ndpi_free = __ndpi_
|
||||
|
||||
void set_ndpi_debug_function(struct ndpi_detection_module_struct *ndpi_str, ndpi_debug_function_ptr ndpi_debug_printf) {
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
ndpi_str->ndpi_debug_printf = ndpi_debug_printf;
|
||||
if (ndpi_debug_printf != NULL)
|
||||
ndpi_str->ndpi_debug_printf = ndpi_debug_printf;
|
||||
else
|
||||
ndpi_str->ndpi_debug_printf = (ndpi_debug_function_ptr) printf;
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1727,7 +1730,7 @@ struct ndpi_detection_module_struct *ndpi_init_detection_module(void) {
|
||||
|
||||
if(ndpi_str == NULL) {
|
||||
#ifdef NDPI_ENABLE_DEBUG_MESSAGES
|
||||
ndpi_debug_printf(0, NULL, NDPI_LOG_DEBUG, "ndpi_init_detection_module initial malloc failed\n");
|
||||
printf(0, NULL, NDPI_LOG_DEBUG, "ndpi_init_detection_module initial malloc failed\n");
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user