Skip to content

Commit

Permalink
Revert "Move reserved handle check to C++ too"
Browse files Browse the repository at this point in the history
This reverts commit e15a9f7.
  • Loading branch information
RReverser committed Oct 13, 2023
1 parent 81fdb3c commit 0510c71
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/embind/emval.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ var LibraryEmVal = {

_emval_free__deps: ['$emval_handles'],
_emval_free: (handle) => {
emval_handles.free(handle);
if (handle >= emval_handles.reserved) {
emval_handles.free(handle);
}
},

_emval_run_destructors__deps: ['_emval_free', '$Emval', '$runDestructors'],
Expand Down
11 changes: 4 additions & 7 deletions system/include/emscripten/val.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ void _emval_register_symbol(const char*);

enum {
_EMVAL_UNDEFINED = 1,
_EMVAL_NULL,
_EMVAL_TRUE,
_EMVAL_FALSE,
_EMVAL_UNRESERVED_START
_EMVAL_NULL = 2,
_EMVAL_TRUE = 3,
_EMVAL_FALSE = 4
};

typedef struct _EM_DESTRUCTORS* EM_DESTRUCTORS;
Expand Down Expand Up @@ -340,9 +339,7 @@ struct val_metadata {

// should be only accessible from dec_ref
~val_metadata() {
if (handle >= EM_VAL(internal::_EMVAL_UNRESERVED_START)) {
internal::_emval_free(handle);
}
_emval_free(handle);
}
};

Expand Down

0 comments on commit 0510c71

Please sign in to comment.