laverdet / isolated-vm

Secure & isolated JS environments for nodejs
ISC License
2.18k stars 154 forks source link

fix incorrect types of pointers #465

Closed ferjakub closed 6 months ago

ferjakub commented 7 months ago

1/ isolate_handle.cc:

snapshot.data, which is allocated by V8 as new char[] (snapshot.cc:546) is owned by snapshot_data_ptr, which is of type unique_ptr<const char> => delete is called upon destruction, delete[] should be called instead

=> changed the type of the unique_ptr to reflect this


2/ scheduler.cc:

uv_async is allocated as uv_async_t (128 B) but deleted as uv_handle_t (96 B)

=> added a cast back from uv_handle_t* to uv_async_t* before deleting


Technically, these situations are UB, but practically they don't cause any issues. They came up as a result of running the test suite with ASan which doesn't complain anymore after this trivial fix.

laverdet commented 6 months ago

Thanks!