From e7be497d80d76796d434a212d2599b33405010dc Mon Sep 17 00:00:00 2001 From: Bill-Gray Date: Mon, 15 Apr 2024 18:09:20 -0400 Subject: [PATCH] Valgrind warned of possible reading of uninitialized memory if extract_lat_lon() was fed a 'buff' consisting only of zero or more spaces. In such a case, we strchr( compass, '\0');, get a non-zero pointer, and cheerfully advance past the end of the array. --- mpc_code.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mpc_code.cpp b/mpc_code.cpp index 2f9d1c2..522f988 100644 --- a/mpc_code.cpp +++ b/mpc_code.cpp @@ -525,6 +525,8 @@ static int extract_lat_lon( const char *buff, size_t *bytes_read, double *value) while( *tptr == ' ') tptr++; + if( !*tptr) + return( GOT_NOTHING); if( strchr( compass, *tptr)) compass_byte = *tptr++; if( !strncasecmp( tptr, "alt", 3))