Skip to content

Commit 792e13d

Browse files
committed
Actually return NMEA string with CRLF
1 parent b9abc83 commit 792e13d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/NMEA_build.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,11 +566,12 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
566566
addChecksum(nmea); // Successful completion
567567
if (!noCRLF) { // Add Carriage Return and Line Feed to comply with NMEA-183
568568
size_t len = strlen(nmea);
569-
char *newStr =
569+
char *nmeaWithCRLF =
570570
(char *)malloc(len + 3); // +2 for \r\n, +1 for null terminator
571-
if (newStr) {
572-
strcpy(newStr, nmea); // Copy original string
573-
strcat(newStr, "\r\n"); // Append \r\n
571+
if (nmeaWithCRLF) {
572+
strcpy(nmeaWithCRLF, nmea); // Copy original string
573+
strcat(nmeaWithCRLF, "\r\n"); // Append \r\n
574+
return nmeaWithCRLF; // return pointer to finished product
574575
}
575576
}
576577
return nmea; // return pointer to finished product

0 commit comments

Comments
 (0)