Possible minor memory leak

26 views
Skip to first unread message

Paul J

unread,
Jun 9, 2025, 7:51:21 AM6/9/25
to golden-cheetah-developers
Whilst looking through the code I noticed in FileIO/JouleDevice.cpp that the result char array is not deleted on exit, the returned QString copies result on return and the result memory is leaked?

static QString
cEscape(char *buf, int len)
{
    char *result = new char[4 * len + 1];
    char *tmp = result;
    for (int i = 0; i < len; ++i) {
        if (buf[i] == '"')
            tmp += sprintf(tmp, "\\\"");
        else if (isprint(buf[i]))
            *(tmp++) = buf[i];
        else
            tmp += sprintf(tmp, "\\x%02x", 0xff & (unsigned) buf[i]);
    }
    return result;
}

Also later in  FileIO/JouleDevice.cpp in function JoulePacket::Read() the creation of char arrays is made dependent on platform Q_CC_MSVC, I guess this is due to Windows having a smaller default stack than Linux ?

Paul J

unread,
Jun 9, 2025, 8:15:02 AM6/9/25
to golden-cheetah-developers
The same issue also appears in:

MarcoDevice.cpp
MoxyDevice.cpp
PowerTapDevice.cpp
SyncRideFile.cpp

Ale Martinez

unread,
Jun 26, 2025, 7:23:42 PM6/26/25
to golden-cheetah-developers
Beside the rhetorical questions, do you realize most of these devices were deprecated long time ago, very few users are likely using them and there are no complains and the positive effect will likely be negligible but, if you change the code without any testing -assuming you don't have access to all of these devices- and may be in 2 years a user can say: hey, my 20 years old device worked with 3.7 but it doesn't work anymore now 3.8 is released, do you plan to be available for debugging?

Paul J

unread,
Jun 27, 2025, 3:13:07 AM6/27/25
to golden-cheetah-developers
I didn't appreciate that these devices have been deprecated for sometime, so now understand why my PR was rejected.

I'm happy to provide future support for all my PRs

Reply all
Reply to author
Forward
0 new messages