Fix realloc error handling in threshold.config file parsing. Bug #1062.

pull/699/head
Victor Julien 12 years ago
parent 35298a0146
commit b4631794a8

@ -1149,14 +1149,20 @@ void SCThresholdConfParseFile(DetectEngineCtx *de_ctx, FILE *fd)
len = SCThresholdConfLineLength(fd); len = SCThresholdConfLineLength(fd);
if (len > 0) { if (len > 0) {
if (line == NULL) if (line == NULL) {
line = SCRealloc(line, len + 1); line = SCMalloc(len + 1);
else if (unlikely(line == NULL)) {
line = SCRealloc(line, strlen(line) + len + 1); SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
return;
if (unlikely(line == NULL)) { }
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory"); } else {
break; char *newline = SCRealloc(line, strlen(line) + len + 1);
if (unlikely(newline == NULL)) {
SCLogError(SC_ERR_MEM_ALLOC, "Error allocating memory");
SCFree(line);
return;
}
line = newline;
} }
if (fgets(line + esc_pos, len + 1, fd) == NULL) if (fgets(line + esc_pos, len + 1, fd) == NULL)

Loading…
Cancel
Save