User Activity

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, #include <stdlib.h> char *buf_new(size_t n) { char *p = malloc(n); return p == NULL ? NULL : p; } char *buf_new2(size_t n) { char *p = malloc(n); return p ? p : NULL; } $ cppcheck -q ternary.c ternary.c:6:5: error: Memory leak: p [memleak] return p == NULL ? NULL : p; ^ ternary.c:12:5: error: Memory leak: p [memleak] return p ? p : NULL; ^ In both functions p is returned to the caller on every path, so nothing leaks. The same check written as an if is not reported: #include <stdlib.h> char *buf_new(size_t...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, Cppcheck reports an error for the "exception dispatcher" idiom when the try { throw; } is not the first statement of the function: #include <exception> #include <string> std::string describeCurrentException() { if (!std::current_exception()) return "no exception"; try { throw; } catch (const std::exception& e) { return e.what(); } catch (...) { return "unknown exception"; } } $ cppcheck -q rethrow.cpp rethrow.cpp:8:9: error: Rethrowing current exception with 'throw;', it seems there is no current...

  • Posted a comment on discussion General Discussion on cppcheck

    Hi, I don't have a Trac account, so I'm reporting this here. Could someone please create a ticket? Suggested component: Other (or Check STL). Version: 2.20. Still present on main (e61884466). The container out-of-bounds checks report CWE-398 (Indicator of Poor Code Quality), but they report an out-of-bounds memory access, which most checks report as CWE-788. CWE-398 makes these errors look like style findings to tools and users that filter or triage by CWE. The CWE is set in lib/checkstl.cpp: containerOutOfBounds:...

View All

Personal Data

Username:
kaixuanli0131
Joined:
2026-11-16 06:43:55.569000

Projects

  • No projects to display.

Personal Tools