diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index edb5a9cafb..375ca543c1 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -50,11 +50,12 @@ static int parse_field(const void *data, size_t length, const char *field, char nl = length - fl; buf = malloc(nl+1); - memcpy(buf, (const char*) data + fl, nl); - ((char*)buf)[nl] = 0; if (!buf) return log_oom(); + memcpy(buf, (const char*) data + fl, nl); + ((char*)buf)[nl] = 0; + free(*target); *target = buf; *target_size = nl;