Fix parsing the eeprom when there are users with no records
[visomat-utils.git] / src / visomat-data-downloader.c
index c2b8590..97da8e8 100644 (file)
@@ -156,6 +156,13 @@ static int decode_eeprom(unsigned char *buffer,
                        /* user_id and num_records take 3 bytes */
                        i += 3;
 
+                       /*
+                        * when there are no records, there is a dummy byte
+                        * which has to be consumed
+                        */
+                       if (num_records == 0)
+                               i += 1;
+
                        for (j = 0; j < num_records; j++) {
                                ret = extract_datetime(buffer + i, &d);
                                if (ret < 0)