Skip to content

Conversation

@matt335672
Copy link
Member

Update to cppcheck 2.18.0

This version of cppcheck is generating false positives on xrdp/xrdp_tconfig.c. This change works around that, but I've also sent a message to https://sourceforge.net/p/cppcheck/discussion/general/ to raise an issue. There's no issue yet, as are some hoops to jump through. However, I've sent this test program which illustrates the false positive:-

#include <stdlib.h>

struct test
{
    int valid;
    char *mem;
};

static struct test get_alloc(void)
{
    struct test result = {0, NULL};

    if ((result.mem = malloc(10)) != NULL)
    {
        result.valid = 1;
    }

    return result;
}

int main()
{
    struct test t;

    t = get_alloc();
    if (t.valid)
    {
        free(t.mem);
    }

    t = get_alloc();
    if (t.valid)
    {
        free(t.mem);
    }
}

Then:-

$ ~/cppcheck.local/2.18.0/bin/cppcheck temp.c
Checking temp.c ...
temp.c:34:9: error: Memory pointed to by 'mem' is freed twice. [doubleFree]
        free(t.mem);
        ^
temp.c:28:9: note: Memory pointed to by 'mem' is freed twice.
        free(t.mem);
        ^
temp.c:34:9: note: Memory pointed to by 'mem' is freed twice.
        free(t.mem);
        ^

I'm marking this draft for now, pending a response from the cppcheck team.

@firewave - you asked to be notified of any cppcheck issues.

@matt335672
Copy link
Member Author

matt335672 commented Jul 31, 2025

cppcheck trac ticket created:-

https://trac.cppcheck.net/ticket/14039#ticket

@firewave
Copy link
Contributor

I think this should be merged - after a bump to 2.18.3 and a rebase.

@matt335672
Copy link
Member Author

Bumped to 2.18.3 and rebased.

@firewave - there appears to be no progress on the TRAC ticket, and it's not in a milestone. Do I take it this is unlikely to be fixed in the near future?

@firewave
Copy link
Contributor

firewave commented Nov 1, 2025

Do I take it this is unlikely to be fixed in the near future?

Yes. If you do not see any progress within a few days or hours that is usually the case.

@matt335672 matt335672 marked this pull request as ready for review November 3, 2025 10:39
@matt335672 matt335672 merged commit 9e1a8d7 into neutrinolabs:devel Nov 3, 2025
26 of 27 checks passed
@matt335672 matt335672 deleted the cppcheck_2_18 branch November 3, 2025 10:40
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 this pull request may close these issues.

2 participants