blueloveTH 3 лет назад
Родитель
Сommit
1be6d72a97
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      src/error.h

+ 5 - 0
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<SourceMetadata> _Source;