fix(libscap/gvisor): use consistent new/delete functions for gvisor platform #1599
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
/kind cleanup
Any specific area of the project related to this PR?
/area libscap-engine-gvisor
Does this PR require a change in the driver versions?
No
What this PR does / why we need it:
It is undefined behavior to allocate memory with
![Screenshot 2023-12-20 at 15 42 43](https://private-user-images.githubusercontent.com/35580196/291967345-4f263852-c327-4254-9cd5-fbc06a5df3e7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5MDgyNTEsIm5iZiI6MTczODkwNzk1MSwicGF0aCI6Ii8zNTU4MDE5Ni8yOTE5NjczNDUtNGYyNjM4NTItYzMyNy00MjU0LTljZDUtZmJjMDZhNWRmM2U3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA3VDA1NTkxMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYzZWRmOGFlZThmZjNlY2ExM2ZjMTliYmM5NTRmODA4OWI4OWVhOWJhMmRlZDRmNWNmMzY1ZGMwYzRiZWVjNzAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.U5xNyXhBFirbdP3IZLz0fqx3gxDP1hxqg69h5Gdomg8)
calloc()
and release it withdelete()
. This fixes it. In C++,new T();
will zero-initialize the allocated memory. Don't believe me? The standard says so and the compiler agrees (below):Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?: