logging: prevent double-free multi-threaded logging

When multithreaded output was enabled, all threads freed
shallow-copy of sensor and prefix names.

This commit adds a guard so that only the parent frees the
allocated buffers.

Ticket: 8861
pull/16141/head
Lukas Sismis 4 weeks ago committed by Victor Julien
parent 3d42f7cf63
commit 7ca9471145

@ -983,17 +983,20 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
SCMutexDestroy(&lf_ctx->fp_mutex);
}
if (lf_ctx->parent == NULL) {
if (lf_ctx->prefix != NULL) {
SCFree(lf_ctx->prefix);
lf_ctx->prefix_len = 0;
}
if (lf_ctx->sensor_name != NULL) {
SCFree(lf_ctx->sensor_name);
}
}
if(lf_ctx->filename != NULL)
SCFree(lf_ctx->filename);
if (lf_ctx->sensor_name)
SCFree(lf_ctx->sensor_name);
if (!lf_ctx->threaded) {
OutputUnregisterFileRotationFlag(&lf_ctx->rotation_flag);
}

Loading…
Cancel
Save