From ad78464e735cf9186ea63417a095ebd1043a8563 Mon Sep 17 00:00:00 2001 From: Haris <4259838+Wulf@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:46:52 -0400 Subject: [PATCH] Fix memory safety issue, thanks @thomasjm More details: https://github.com/Wulf/nodehun/pull/121#issuecomment-3685148908 --- src/Nodehun.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Nodehun.cc b/src/Nodehun.cc index e1a841a..a96c50a 100644 --- a/src/Nodehun.cc +++ b/src/Nodehun.cc @@ -65,7 +65,9 @@ Nodehun::Nodehun(const Napi::CallbackInfo& info) : Napi::ObjectWrap(inf Napi::Buffer affixBuffer = info[0].As>(); Napi::Buffer dictionaryBuffer = info[1].As>(); - context = new HunspellContext(new Hunspell(affixBuffer.Data(), dictionaryBuffer.Data(), NULL, true)); + std::string affixStr(affixBuffer.Data(), affixBuffer.Length()); + std::string dictionaryStr(dictionaryBuffer.Data(), dictionaryBuffer.Length()); + context = new HunspellContext(new Hunspell(affixStr.c_str(), dictionaryStr.c_str(), NULL, true)); }; Nodehun::~Nodehun() {