Skip to content
This repository has been archived by the owner on Jul 22, 2023. It is now read-only.

BSP MEM POSIX realloc impl NULL input ptr handling, diff. vs. C standard #125

Open
atigyi opened this issue May 28, 2021 · 2 comments
Open

Comments

@atigyi
Copy link
Contributor

atigyi commented May 28, 2021

The SDK BSP MEM's realloc implementation does not enforce C standard behaviour. This is required if the underlying platform's realloc function doesn't meet the standard. In this particular case the behaviour on NULL input ptr value differs from the standard (below) for Raspberry Pi / ARM architecture.

iot-device-sdk's POSIX realloc function impl.

realloc - memory reallocator : "If ptr is a null pointer, realloc() shall be equivalent to malloc() for the specified size."
C realloc C standard definition.

Some more details

  • Seems "only" the Wolfssl uses realloc and/or uses 'realloc' with NULL ptr input.
  • The SDK actually propagates the standard C adherence to the underlying platform's realloc function by only forwarding the parameters intact, without applying any logic.
@sridharan-8888
Copy link

Additional info on the issue, it seems to be related to 'memory_limitter'

@atigyi
Copy link
Contributor Author

atigyi commented Jun 20, 2021

Indeed, this isn't C standard compatible. Did you conduct tests with if-null-return-null lines removed?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants