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

Fix mismatched C free of memory allocated with C++ new #220

Merged
merged 3 commits into from
Nov 2, 2021

Conversation

dylanahsmith
Copy link
Collaborator

Problem

There were a couple of places where C++ new was used in v8go.cc, then C.free was used on that pointer in Go.

Mixing these is technically undefined behaviour, even though new and delete is often implemented as a wrapper around malloc and free

Solution

I used malloc to allocate these values so they can be safely freed using C.free.

Looks like clang-format was missed on the existing code in master, so using that produced some more noise to this change, but I isolated that to the second commit in this PR

@codecov
Copy link

codecov bot commented Oct 29, 2021

Codecov Report

Merging #220 (2a5759c) into master (ea7debf) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #220   +/-   ##
=======================================
  Coverage   95.59%   95.59%           
=======================================
  Files          16       16           
  Lines         545      545           
=======================================
  Hits          521      521           
  Misses         15       15           
  Partials        9        9           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ea7debf...2a5759c. Read the comment docs.

@dylanahsmith dylanahsmith merged commit 24e3ca7 into master Nov 2, 2021
@dylanahsmith dylanahsmith deleted the mismatched-new-free branch November 2, 2021 17:25
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