Skip to content

Commit 605dfc3

Browse files
committed
Add suggested fix
1 parent 792e13d commit 605dfc3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/NMEA_build.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@ char *Adafruit_GPS::build(char *nmea, const char *thisSource,
571571
if (nmeaWithCRLF) {
572572
strcpy(nmeaWithCRLF, nmea); // Copy original string
573573
strcat(nmeaWithCRLF, "\r\n"); // Append \r\n
574-
return nmeaWithCRLF; // return pointer to finished product
574+
strcpy(nmea, nmeaWithCRLF); // Copy back to original buffer
575+
free(nmeaWithCRLF); // Free the allocated memory
575576
}
576577
}
577578
return nmea; // return pointer to finished product

0 commit comments

Comments
 (0)