chiark / gitweb /
logs-show: fix OOM path
authorLennart Poettering <lennart@poettering.net>
Thu, 26 Jul 2012 14:05:26 +0000 (16:05 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 26 Jul 2012 14:56:21 +0000 (16:56 +0200)
src/shared/logs-show.c

index edb5a9c..375ca54 100644 (file)
@@ -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;