Title: Fix Uncontrolled Recursion in `simplifyAddBracesToCommand` by emptyiscolor · Pull Request #8264 · cppcheck-opensource/cppcheck · GitHub
Open Graph Title: Fix Uncontrolled Recursion in `simplifyAddBracesToCommand` by emptyiscolor · Pull Request #8264 · cppcheck-opensource/cppcheck
X Title: Fix Uncontrolled Recursion in `simplifyAddBracesToCommand` by emptyiscolor · Pull Request #8264 · cppcheck-opensource/cppcheck
Description: Related case: https://sourceforge.net/p/cppcheck/discussion/development/thread/eea4fd963a/ Applied Fix — Recursion Depth Limit Added an int depth parameter (default 0) to both functions. Every recursive call passes depth + 1, and at the top of simplifyAddBracesToCommand we bail out when depth > 500: Test Both PoC vectors (100K else if chain and 50K nested if) no longer cause a stack overflow by running the PY code from the discussion. Normal code continues to be analyzed correctly. Alternative Fix — Iterative Approach The else if chain recursion (Path 1) can be eliminated by converting the tail-recursive call into a loop inside simplifyAddBracesToCommand. This eliminates Path 1 (else-if chain) with zero stack growth regardless of chain length. Path 2 (mutual recursion with simplifyAddBracesPair) would still need a depth limit or its own iterative conversion using an explicit stack/worklist. A full iterative conversion of both paths is a larger refactor but would make the code completely immune to stack overflow from any input shape.
Open Graph Description: Related case: https://sourceforge.net/p/cppcheck/discussion/development/thread/eea4fd963a/ Applied Fix — Recursion Depth Limit Added an int depth parameter (default 0) to both functions. Every recu...
X Description: Related case: https://sourceforge.net/p/cppcheck/discussion/development/thread/eea4fd963a/ Applied Fix — Recursion Depth Limit Added an int depth parameter (default 0) to both functions. Every recu...
Opengraph URL: https://github.com/cppcheck-opensource/cppcheck/pull/8264
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:19d05438-5be8-610a-5b2f-6ed9ecffd6e4 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8048:397AD8:1C00AD9:2639A70:6A4F3511 |
| html-safe-nonce | 5fb84912ef8641f63c86c3ecee3507c9342b1fa247018d0c0741ea7d7cb64354 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDQ4OjM5N0FEODoxQzAwQUQ5OjI2MzlBNzA6NkE0RjM1MTEiLCJ2aXNpdG9yX2lkIjoiMTE4MDkwNTUxMTgzNjM5ODg2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c91e214032c69964d51d960288f46922e79b6ca767b1f0c8b5f75915e1669a30 |
| hovercard-subject-tag | pull_request:3326598437 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/cppcheck-opensource/cppcheck/pull/8264/files |
| twitter:image | https://avatars.githubusercontent.com/u/7723517?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/7723517?s=400&v=4 |
| og:image:alt | Related case: https://sourceforge.net/p/cppcheck/discussion/development/thread/eea4fd963a/ Applied Fix — Recursion Depth Limit Added an int depth parameter (default 0) to both functions. Every recu... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | b92d11c0aa4a77d54ef4af1078b6a15fb5a70a215b30c4ecf28889d5a8e656d9 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/cppcheck-opensource/cppcheck git https://github.com/cppcheck-opensource/cppcheck.git |
| octolytics-dimension-user_id | 278097703 |
| octolytics-dimension-user_login | cppcheck-opensource |
| octolytics-dimension-repository_id | 143131 |
| octolytics-dimension-repository_nwo | cppcheck-opensource/cppcheck |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 143131 |
| octolytics-dimension-repository_network_root_nwo | cppcheck-opensource/cppcheck |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b8f23afb982271f1b22258a94aede67a6b77760 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width