chiark / gitweb /
util: don't fail if no id was passed to detect_container()
authorLennart Poettering <lennart@poettering.net>
Fri, 23 Sep 2011 03:33:33 +0000 (05:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 23 Sep 2011 14:28:27 +0000 (16:28 +0200)
src/util.c

index 33b6fd48098da4626791be19a91ba1b448fec49e..ed3b8d421ac5b0f2905d666cba8d25974e28914c 100644 (file)
@@ -4445,17 +4445,23 @@ int detect_container(const char **id) {
 
                         if (streq(line, "container=lxc")) {
                                 fclose(f);
-                                *id = "lxc";
+
+                                if (id)
+                                        *id = "lxc";
                                 return 1;
 
                         } else if (streq(line, "container=systemd-nspawn")) {
                                 fclose(f);
-                                *id = "systemd-nspawn";
+
+                                if (id)
+                                        *id = "systemd-nspawn";
                                 return 1;
 
                         } else if (startswith(line, "container=")) {
                                 fclose(f);
-                                *id = "other-container";
+
+                                if (id)
+                                        *id = "other-container";
                                 return 1;
                         }