From 1be6d72a976f4de4d28d120dc7709a3d72d80106 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Fri, 11 Nov 2022 19:35:31 +0800 Subject: [PATCH] Update error.h --- src/error.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/error.h b/src/error.h index 653cc071..a81c9019 100644 --- a/src/error.h +++ b/src/error.h @@ -30,6 +30,7 @@ struct SourceMetadata { } SourceMetadata(const char* source, _Str filename, CompileMode mode) { + source = strdup(source); // Skip utf8 BOM if there is any. if (strncmp(source, "\xEF\xBB\xBF", 3) == 0) source += 3; this->filename = filename; @@ -46,6 +47,10 @@ struct SourceMetadata { ss << " " << line << '\n'; return ss.str(); } + + ~SourceMetadata(){ + free((void*)source); + } }; typedef std::shared_ptr _Source;