redis-output: fix sensor-name code

The sensor-name was not freed at exist and the result of SCStrdup
was not checked.
pull/1712/head
Eric Leblond 11 years ago committed by Victor Julien
parent 594f62b523
commit f11b269ef1

@ -546,6 +546,12 @@ OutputCtx *OutputJsonInitCtx(ConfNode *conf)
sensor_name = hostname; sensor_name = hostname;
} }
json_ctx->file_ctx->redis_setup.sensor_name = SCStrdup(sensor_name); json_ctx->file_ctx->redis_setup.sensor_name = SCStrdup(sensor_name);
if (json_ctx->file_ctx->redis_setup.sensor_name == NULL) {
LogFileFreeCtx(json_ctx->file_ctx);
SCFree(json_ctx);
SCFree(output_ctx);
return NULL;
}
if (SCConfLogOpenRedis(redis_node, json_ctx->file_ctx) < 0) { if (SCConfLogOpenRedis(redis_node, json_ctx->file_ctx) < 0) {
LogFileFreeCtx(json_ctx->file_ctx); LogFileFreeCtx(json_ctx->file_ctx);

@ -500,6 +500,7 @@ int LogFileFreeCtx(LogFileCtx *lf_ctx)
SCFree(lf_ctx->redis_setup.server); SCFree(lf_ctx->redis_setup.server);
SCFree(lf_ctx->redis_setup.command); SCFree(lf_ctx->redis_setup.command);
SCFree(lf_ctx->redis_setup.key); SCFree(lf_ctx->redis_setup.key);
SCFree(lf_ctx->redis_setup.sensor_name);
} }
#endif #endif

Loading…
Cancel
Save