Fixed restoration of the panel divider position.
[psensor.git] / src / lib / psensor_json.c
index fcb0982..14e69e0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2014 jeanfi@gmail.com
+ * Copyright (C) 2010-2016 jeanfi@gmail.com
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
@@ -119,14 +119,16 @@ char *sensors_to_json_string(struct psensor **sensors)
        char *str;
        json_object *obj = json_object_new_array();
 
-       sensors_cur = sensors;
+       if (sensors) {
+               sensors_cur = sensors;
 
-       while (*sensors_cur) {
-               struct psensor *s = *sensors_cur;
+               while (*sensors_cur) {
+                       struct psensor *s = *sensors_cur;
 
-               json_object_array_add(obj, sensor_to_json(s));
+                       json_object_array_add(obj, sensor_to_json(s));
 
-               sensors_cur++;
+                       sensors_cur++;
+               }
        }
 
        str = strdup(json_object_to_json_string(obj));