tree-sitter / node-tree-sitter

Node.js bindings for tree-sitter
https://www.npmjs.com/package/tree-sitter
MIT License
649 stars 114 forks source link

fix: prevent Nan::Utf8String destructor call due to out of scope #81

Closed ahlinc closed 3 years ago

ahlinc commented 3 years ago

Fixes #72 This PR resolves the issue due to automatic Nan::Utf8String destructor call due to outing of scope on line 108 what leads to:

source == "\0"
source_len > 0

so ts_query_new function would try to read a lot of bytes from a string contained in the destructed Nan::Utf8String object whose memory is most likely to be freed already in case of a long input string.

maxbrunsfeld commented 3 years ago

Thanks!