comparison 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
comparison
equal deleted inserted replaced
44:2468e2f2456c 45:ee76cced46a5
19 19
20 #pragma once 20 #pragma once
21 21
22 #include "PythonObject.h" 22 #include "PythonObject.h"
23 23
24 #include <Compatibility.h> // For std::unique_ptr
25
24 // A Python string is always valid, or an exception was thrown on its creation 26 // A Python string is always valid, or an exception was thrown on its creation
25 class PythonString : public boost::noncopyable 27 class PythonString : public boost::noncopyable
26 { 28 {
27 private: 29 private:
28 PythonObject string_; 30 std::unique_ptr<PythonObject> string_;
31
32 void SanityCheck();
29 33
30 public: 34 public:
31 PythonString(PythonLock& lock, 35 PythonString(PythonLock& lock,
32 const std::string& utf8); 36 const std::string& utf8);
33 37
38 PythonString(PythonLock& lock,
39 const char* utf8);
40
34 PyObject* GetPyObject() const 41 PyObject* GetPyObject() const
35 { 42 {
36 return string_.GetPyObject(); 43 return string_->GetPyObject();
44 }
45
46 PyObject* Release()
47 {
48 return string_->Release();
37 } 49 }
38 }; 50 };