Skip to content

Commit a4c80fb

Browse files
committed
Cppcheck does not know how FormatMessage() works. Ignore the message.
Add LocalFree() to prevent leak.
1 parent d833638 commit a4c80fb

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/emc/usr_intf/sockets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,12 @@ char* sockGetError(void)
276276

277277
/* append the message text after the error code and ensure a terminating
278278
character ends the string */
279+
// The 'tmp' buffer is allocated by FormatMessage().
280+
// cppcheck-suppress nullPointer
279281
strncpy(retString + strlen(retString), tmp,
280282
sizeof(retString) - strlen(retString) - 1);
281283
retString[sizeof(retString) - 1] = '\0';
284+
LocalFree(tmp);
282285

283286
return retString;
284287
#endif

0 commit comments

Comments
 (0)