... | ... |
@@ -390,24 +390,29 @@ struct cl_engine *cl_engine_new(void) |
390 | 390 |
|
391 | 391 |
/* Set up default stats/intel gathering callbacks */ |
392 | 392 |
intel = cli_calloc(1, sizeof(cli_intel_t)); |
393 |
+ if ((intel)) { |
|
393 | 394 |
#ifdef CL_THREAD_SAFE |
394 |
- if (pthread_mutex_init(&(intel->mutex), NULL)) { |
|
395 |
- cli_errmsg("cli_engine_new: Cannot initialize stats gathering mutex\n"); |
|
396 |
- mpool_free(new->mempool, new->dconf); |
|
397 |
- mpool_free(new->mempool, new->root); |
|
395 |
+ if (pthread_mutex_init(&(intel->mutex), NULL)) { |
|
396 |
+ cli_errmsg("cli_engine_new: Cannot initialize stats gathering mutex\n"); |
|
397 |
+ mpool_free(new->mempool, new->dconf); |
|
398 |
+ mpool_free(new->mempool, new->root); |
|
398 | 399 |
#ifdef USE_MPOOL |
399 |
- mpool_destroy(new->mempool); |
|
400 |
+ mpool_destroy(new->mempool); |
|
400 | 401 |
#endif |
401 |
- free(new); |
|
402 |
- free(intel); |
|
403 |
- return NULL; |
|
404 |
- } |
|
402 |
+ free(new); |
|
403 |
+ free(intel); |
|
404 |
+ return NULL; |
|
405 |
+ } |
|
405 | 406 |
#endif |
406 |
- intel->engine = new; |
|
407 |
- intel->maxsamples = STATS_MAX_SAMPLES; |
|
408 |
- intel->maxmem = STATS_MAX_MEM; |
|
409 |
- intel->timeout = 10; |
|
410 |
- new->stats_data = intel; |
|
407 |
+ intel->engine = new; |
|
408 |
+ intel->maxsamples = STATS_MAX_SAMPLES; |
|
409 |
+ intel->maxmem = STATS_MAX_MEM; |
|
410 |
+ intel->timeout = 10; |
|
411 |
+ new->stats_data = intel; |
|
412 |
+ } else { |
|
413 |
+ new->stats_data = NULL; |
|
414 |
+ } |
|
415 |
+ |
|
411 | 416 |
new->cb_stats_add_sample = NULL; |
412 | 417 |
new->cb_stats_submit = NULL; |
413 | 418 |
new->cb_stats_flush = clamav_stats_flush; |
... | ... |
@@ -806,12 +811,6 @@ int cl_engine_settings_apply(struct cl_engine *engine, const struct cl_settings |
806 | 806 |
engine->cb_hash = settings->cb_hash; |
807 | 807 |
engine->cb_meta = settings->cb_meta; |
808 | 808 |
|
809 |
- intel = (cli_intel_t *)cli_calloc(1, sizeof(cli_intel_t)); |
|
810 |
- intel->engine = engine; |
|
811 |
- intel->maxsamples = STATS_MAX_SAMPLES; |
|
812 |
- intel->maxmem = STATS_MAX_MEM; |
|
813 |
- |
|
814 |
- engine->stats_data = (void *)intel; |
|
815 | 809 |
engine->cb_stats_add_sample = settings->cb_stats_add_sample; |
816 | 810 |
engine->cb_stats_remove_sample = settings->cb_stats_remove_sample; |
817 | 811 |
engine->cb_stats_decrement_count = settings->cb_stats_decrement_count; |
... | ... |
@@ -471,7 +471,7 @@ void clamav_stats_decrement_count(const char *virname, const unsigned char *md5, |
471 | 471 |
|
472 | 472 |
sample = find_sample(intel, virname, md5, size, NULL); |
473 | 473 |
if (!(sample)) |
474 |
- return; |
|
474 |
+ goto clamav_stats_decrement_end; |
|
475 | 475 |
|
476 | 476 |
if (sample->hits == 1) { |
477 | 477 |
if ((intel->engine->cb_stats_remove_sample)) |
... | ... |
@@ -479,11 +479,12 @@ void clamav_stats_decrement_count(const char *virname, const unsigned char *md5, |
479 | 479 |
else |
480 | 480 |
clamav_stats_remove_sample(virname, md5, size, intel); |
481 | 481 |
|
482 |
- return; |
|
482 |
+ goto clamav_stats_decrement_end; |
|
483 | 483 |
} |
484 | 484 |
|
485 | 485 |
sample->hits--; |
486 | 486 |
|
487 |
+ clamav_stats_decrement_end: |
|
487 | 488 |
#ifdef CL_THREAD_SAFE |
488 | 489 |
err = pthread_mutex_unlock(&(intel->mutex)); |
489 | 490 |
if (err) { |