if (priority == LOG_INFO) {
unsigned int length = 0;
+ // Create a copy of line
+ char* message = strdup(line);
+ if (!message)
+ return 1;
+
+ // Remove any trailing newline
+ pakfire_remove_trailing_newline(message);
+
// Determine the length of the existing array
if (*array) {
for (char** element = *array; *element; element++)
if (!*array)
return 1;
- // Append line and terminate the array
- (*array)[length] = strdup(line);
+ // Append message and terminate the array
+ (*array)[length] = message;
(*array)[length + 1] = NULL;
return 0;