File tree Expand file tree Collapse file tree 2 files changed +18
-5
lines changed
Expand file tree Collapse file tree 2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change 11name =Adafruit IO Arduino
2- version =4.3.4
2+ version =4.3.5
33author =Adafruit
44maintainer =Adafruit <adafruitio@adafruit.com>
55sentence =Arduino library to access Adafruit IO.
Original file line number Diff line number Diff line change @@ -823,6 +823,21 @@ char **parse_csv(const char *line) {
823823 fQuote = 1 ;
824824 continue ;
825825 case ' \0 ' :
826+ // Emit the final field. Previously this was dropped on the floor
827+ // because the null terminator only set fEnd and broke the loop,
828+ // so parse_csv() returned one fewer field than count_fields()
829+ // reported. Callers reading fields[n-1] would then dereference NULL.
830+ *tptr = ' \0 ' ;
831+ *bptr = strdup (tmp);
832+ if (!*bptr) {
833+ for (bptr--; bptr >= buf; bptr--) {
834+ free (*bptr);
835+ }
836+ free (buf);
837+ free (tmp);
838+ return NULL ;
839+ }
840+ bptr++;
826841 fEnd = 1 ;
827842 break ;
828843 case ' ,' :
@@ -890,12 +905,12 @@ bool AdafruitIO_Data::_parseCSV() {
890905 }
891906
892907 if (field_count > 0 ) {
893- _lon = atof (fields[1 ]);
908+ _lon = atof (fields[2 ]);
894909 field_count--;
895910 }
896911
897912 if (field_count > 0 ) {
898- _ele = atof (fields[1 ]);
913+ _ele = atof (fields[3 ]);
899914 field_count--;
900915 }
901916
@@ -910,6 +925,4 @@ bool AdafruitIO_Data::_parseCSV() {
910925 } else {
911926 return false ;
912927 }
913-
914- return true ;
915928}
You can’t perform that action at this time.
0 commit comments