8000 csp_buffer: Fix pointers in csp_buffer_clone by moonlight83340 · Pull Request #834 · libcsp/libcsp · GitHub
[go: up one dir, main page]

Skip to content

csp_buffer: Fix pointers in csp_buffer_clone #834

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

moonlight83340
Copy link
Contributor

This PR have 2 commits.

Commit 1 :
The frame_begin pointer was introduced in commit 5ee2d36, but csp_buffer_clone()
was not updated accordingly.

As a result, cloned packets would end up with a frame_begin pointer referencing
the original packet’s memory, which is incorrect and unsafe.

This commit fixes the issue by recalculating frame_begin after copying the
packet, ensuring it points to the correct memory area within the new buffer.

Commit 2 :
Add unit tests to verify that the frame_begin pointer in a cloned packet points
to the correct memory region within the clone.

The tests also confirm that modifying the original packet's data does not affect
the cloned packet, ensuring proper memory separation between the two.

The frame_begin pointer was introduced in commit 5ee2d36, but csp_buffer_clone()
was not updated accordingly.

As a result, cloned packets would end up with a frame_begin pointer referencing
the original packet’s memory, which is incorrect and unsafe.

This commit fixes the issue by recalculating frame_begin after copying the
packet, ensuring it points to the correct memory area within the new buffer.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
Add unit tests to verify that the frame_begin pointer in a cloned packet points
to the correct memory region within the clone.

The tests also confirm that modifying the original packet's data does not affect
the cloned packet, ensuring proper memory separation between the two.

Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
@moonlight83340 moonlight83340 marked this pull request as ready for review April 13, 2025 14:32
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.

1 participant
0