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

Simpler fix for Dangling Pointer issue #2675

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

mikee47
Copy link
Contributor

@mikee47 mikee47 commented Oct 12, 2023

Whilst using a function to 'hide' the stack return appears to work, integration tests fail in a couple of scenarios (FlashString, RapidXML) because of the way stack space gets used. For Host builds, the most pragmatic solution is to make _F(s) return s directly. That means it gives a const char* rather than char*, and any attempt to pass this to a function requiring a regular char* will fail.

Whilst using a function to 'hide' the stack return appears to work, integration tests fail in a couple of scenarios (FlashString, RapidXML) because of the way stack space gets used.
For Host builds, the most pragmatic solution is to make `_F(s)` return `s` directly.
That means it gives a `const char*` rather than `char*`, and any attempt to pass this to a function requiring a regular `char*` will fail.
@what-the-diff
Copy link

what-the-diff bot commented Oct 12, 2023

PR Summary

  • Removal of smg_return_local function
    The function smg_return_local has been removed from the FakePgmSpace.cpp file. This means we've trimmed off unnecessary code.

  • Modification of smg_return_local macro
    The smg_return_local macro found in FakePgmSpace.h file has been adjusted. Instead of invoking a function, it directly delivers the buffer, which should streamline the process, thus making it a bit more efficient.

  • Addition of _F(str) (str) definition
    A new definition has been added to the FakePgmSpace.h file: _F(str) (str). This can be invoked to simplify specific string-related operations in the code, adding an easy-to-use way to manipulate strings.

@mikee47 mikee47 changed the title Second (and final) attempt at fixing this issue. Second (and final) attempt at fixing Dangling Pointer issue Oct 12, 2023
@mikee47 mikee47 changed the title Second (and final) attempt at fixing Dangling Pointer issue Simpler fix for Dangling Pointer issue Oct 12, 2023
@slaff slaff added this to the 5.1.0 milestone Oct 13, 2023
@slaff slaff merged commit c3834dc into SmingHub:develop Oct 13, 2023
36 checks passed
@mikee47 mikee47 deleted the fix/dangling-pointer-2 branch October 13, 2023 10:50
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