X-Git-Url: https://git.wpitchoune.net/gitweb/?p=psensor.git;a=blobdiff_plain;f=src%2Flib%2Fpsensor_json.c;h=14e69e0166cc039ca6f8410db4e870966aa68f97;hp=fcb09821697f542943d0d3a7c67d1f85e78621a7;hb=c1e20f2631a1249720e9c75d753eacfcb0f6c7b9;hpb=9f2b7eb5cd9f86d72f63a3956a6088e6f0319070 diff --git a/src/lib/psensor_json.c b/src/lib/psensor_json.c index fcb0982..14e69e0 100644 --- a/src/lib/psensor_json.c +++ b/src/lib/psensor_json.c @@ -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));