Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GPS serial memory leak? #1221

Closed
tsteven4 opened this issue Nov 16, 2023 · 2 comments · Fixed by #1223
Closed

GPS serial memory leak? #1221

tsteven4 opened this issue Nov 16, 2023 · 2 comments · Fixed by #1223

Comments

@tsteven4
Copy link
Collaborator

GPS_Serial_On allocates memory for the device header on both windows

int32_t GPS_Serial_On(const char* port, gpsdevh** dh)
{
DCB tio;
COMMTIMEOUTS timeout;
HANDLE comport;
const char* xname = fix_win_serial_name(port);
win_serial_data* wsd = (win_serial_data*) xcalloc(sizeof(win_serial_data), 1);

and posix

gpsbabel/jeeps/gpsserial.cc

Lines 573 to 575 in ad23c57

int32_t GPS_Serial_On(const char* port, gpsdevh** dh)
{
auto* psd = (posix_serial_data*) xcalloc(sizeof(posix_serial_data), 1);

GPS_Serial_Off frees the memory on windows

gpsbabel/jeeps/gpsserial.cc

Lines 164 to 169 in ad23c57

int32_t GPS_Serial_Off(gpsdevh* dh)
{
win_serial_data* wsd = (win_serial_data*)dh;
CloseHandle(wsd->comport);
wsd->comport = INVALID_HANDLE_VALUE;
xfree(wsd);

but not posix.

gpsbabel/jeeps/gpsserial.cc

Lines 599 to 608 in ad23c57

int32_t GPS_Serial_Off(gpsdevh* dh)
{
if (!GPS_Serial_Close(dh)) {
GPS_Error("Error Closing port");
gps_errno = HARDWARE_ERROR;
return 0;
}
return 1;
}

@robertlipe
Copy link
Collaborator

robertlipe commented Nov 16, 2023 via email

@tsteven4
Copy link
Collaborator Author

Thanks for your reply. The leak is confirmed.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants