diff --git a/src/json.hpp b/src/json.hpp
index b581fea1..614a700f 100644
--- a/src/json.hpp
+++ b/src/json.hpp
@@ -7283,7 +7283,7 @@ class basic_json
         explicit lexer(const string_t& s) noexcept
             : m_stream(nullptr), m_buffer(s)
         {
-            m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
+            m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
             assert(m_content != nullptr);
             m_start = m_cursor = m_content;
             m_limit = m_content + s.size();
diff --git a/src/json.hpp.re2c b/src/json.hpp.re2c
index 73185c6b..a7c6f7e7 100644
--- a/src/json.hpp.re2c
+++ b/src/json.hpp.re2c
@@ -7283,7 +7283,7 @@ class basic_json
         explicit lexer(const string_t& s) noexcept
             : m_stream(nullptr), m_buffer(s)
         {
-            m_content = reinterpret_cast<const lexer_char_t*>(s.c_str());
+            m_content = reinterpret_cast<const lexer_char_t*>(m_buffer.c_str());
             assert(m_content != nullptr);
             m_start = m_cursor = m_content;
             m_limit = m_content + s.size();
diff --git a/test/src/unit.cpp b/test/src/unit.cpp
index 8ca9b01f..2a92b327 100644
--- a/test/src/unit.cpp
+++ b/test/src/unit.cpp
@@ -10359,6 +10359,14 @@ TEST_CASE("parser class")
             CHECK(j_empty_array == json());
         }
     }
+
+    SECTION("copy constructor")
+    {
+        json::string_t* s = new json::string_t("[1,2,3,4]");
+        json::parser p(*s);
+        delete s;
+        CHECK(p.parse() == json({1, 2, 3, 4}));
+    }
 }
 
 TEST_CASE("README", "[hide]")