Replace an alloca() call with new_malloc() / new_free()
This also cleans up the code here a bit.
This commit is contained in:
@@ -614,18 +614,24 @@ int logmsg(unsigned long log_type, const char *from, int flag, const char *forma
|
|||||||
lines = split_up_line(stripansicodes(convert_output_format(format, "%s %s %s %s", type, timestr, from, msglog_buffer)), 80);
|
lines = split_up_line(stripansicodes(convert_output_format(format, "%s %s %s %s", type, timestr, from, msglog_buffer)), 80);
|
||||||
for ( ; *lines; lines++)
|
for ( ; *lines; lines++)
|
||||||
{
|
{
|
||||||
char *local_copy;
|
const size_t line_len = strlen(*lines);
|
||||||
int len = strlen(*lines) * 2 + 1;
|
const size_t local_len = line_len * 2 + 1;
|
||||||
if (!*lines || !**lines) break;
|
|
||||||
local_copy = alloca(len);
|
if (line_len > 0)
|
||||||
|
{
|
||||||
|
char *local_copy = new_malloc(local_len);
|
||||||
|
|
||||||
strcpy(local_copy, *lines);
|
strcpy(local_copy, *lines);
|
||||||
|
|
||||||
if (local_copy[strlen(local_copy)-1] == ALL_OFF)
|
if (local_copy[line_len - 1] == ALL_OFF)
|
||||||
local_copy[strlen(local_copy)-1] = 0;
|
local_copy[line_len - 1] = 0;
|
||||||
if (logfile_line_mangler)
|
if (logfile_line_mangler)
|
||||||
mangle_line(local_copy, logfile_line_mangler, len);
|
mangle_line(local_copy, logfile_line_mangler, local_len);
|
||||||
if (*local_copy)
|
if (*local_copy)
|
||||||
fprintf(logptr, "%s\n", local_copy);
|
fprintf(logptr, "%s\n", local_copy);
|
||||||
|
|
||||||
|
new_free(&local_copy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
fflush(logptr);
|
fflush(logptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user