log-http: fix error check leading to null-deref on malloc failure during setup

pull/694/head
Victor Julien 11 years ago
parent 4165bf8951
commit afb48cfcb5

@ -704,7 +704,6 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf)
for (httplog_ctx->cf_n = 0; httplog_ctx->cf_n < LOG_HTTP_MAXN_NODES-1 && p && *p != '\0'; for (httplog_ctx->cf_n = 0; httplog_ctx->cf_n < LOG_HTTP_MAXN_NODES-1 && p && *p != '\0';
httplog_ctx->cf_n++){ httplog_ctx->cf_n++){
httplog_ctx->cf_nodes[httplog_ctx->cf_n] = SCMalloc(sizeof(LogHttpCustomFormatNode)); httplog_ctx->cf_nodes[httplog_ctx->cf_n] = SCMalloc(sizeof(LogHttpCustomFormatNode));
httplog_ctx->cf_nodes[httplog_ctx->cf_n]->maxlen=0;
if (httplog_ctx->cf_nodes[httplog_ctx->cf_n] == NULL) { if (httplog_ctx->cf_nodes[httplog_ctx->cf_n] == NULL) {
for (n = 0; n < httplog_ctx->cf_n; n++) { for (n = 0; n < httplog_ctx->cf_n; n++) {
SCFree(httplog_ctx->cf_nodes[n]); SCFree(httplog_ctx->cf_nodes[n]);
@ -713,6 +712,8 @@ OutputCtx *LogHttpLogInitCtx(ConfNode *conf)
SCFree(httplog_ctx); SCFree(httplog_ctx);
return NULL; return NULL;
} }
httplog_ctx->cf_nodes[httplog_ctx->cf_n]->maxlen = 0;
if (*p != '%'){ if (*p != '%'){
/* Literal found in format string */ /* Literal found in format string */
httplog_ctx->cf_nodes[httplog_ctx->cf_n]->type = LOG_HTTP_CF_LITERAL; httplog_ctx->cf_nodes[httplog_ctx->cf_n]->type = LOG_HTTP_CF_LITERAL;

Loading…
Cancel
Save