diff Sources/PythonString.h @ 45:ee76cced46a5

Fix issue #185 (segfaults on non-UTF8 special characters in request URI)
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 03 Aug 2020 18:13:10 +0200
parents 7ed502b17b8f
children 23f3099bed47
line wrap: on
line diff
--- a/Sources/PythonString.h	Wed Jul 08 15:22:12 2020 +0200
+++ b/Sources/PythonString.h	Mon Aug 03 18:13:10 2020 +0200
@@ -21,18 +21,30 @@
 
 #include "PythonObject.h"
 
+#include <Compatibility.h>  // For std::unique_ptr
+
 // A Python string is always valid, or an exception was thrown on its creation
 class PythonString : public boost::noncopyable
 {
 private:
-  PythonObject  string_;
+  std::unique_ptr<PythonObject>  string_;
+
+  void SanityCheck();
 
 public:
   PythonString(PythonLock& lock,
                const std::string& utf8);
 
+  PythonString(PythonLock& lock,
+               const char* utf8);
+
   PyObject* GetPyObject() const
   {
-    return string_.GetPyObject();
+    return string_->GetPyObject();
+  }
+
+  PyObject* Release()
+  {
+    return string_->Release();
   }
 };