From ae204a483051e1150a128c6b9cdfd924c902499f Mon Sep 17 00:00:00 2001 From: Rukchad Wongprayoon Date: Thu, 10 Apr 2025 02:10:51 +0700 Subject: [PATCH] msvc will never complain ever again --- src/binding.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/binding.cc b/src/binding.cc index 8f97da0..96e70a3 100644 --- a/src/binding.cc +++ b/src/binding.cc @@ -281,8 +281,11 @@ class Magic : public ObjectWrap { } if (fd == -1) { detect_req->free_error = false; - detect_req->error_message = "Error while opening file"; - magic_close(magic); + const char *error_msg = "Error while opening file"; + char* copy = static_cast(malloc(strlen(error_msg) + 1)); + strcpy(copy, error_msg); + detect_req->error_message = copy; + magic_close(magic); return; } result = magic_descriptor(magic, fd);