comparison Sources/OnChangeCallback.cpp @ 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 fd58eb5749ed
children 23f3099bed47
comparison
equal deleted inserted replaced
44:2468e2f2456c 45:ee76cced46a5
17 **/ 17 **/
18 18
19 19
20 #include "OnChangeCallback.h" 20 #include "OnChangeCallback.h"
21 21
22 #include "PythonObject.h" 22 #include "PythonString.h"
23 23
24 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h" 24 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
25 25
26 #include <Compatibility.h> // For std::unique_ptr<> 26 #include <Compatibility.h> // For std::unique_ptr<>
27 27
147 else if (changesCallback_ != NULL) 147 else if (changesCallback_ != NULL)
148 { 148 {
149 try 149 try
150 { 150 {
151 PythonLock lock; 151 PythonLock lock;
152
153 PythonString resourceId(lock, change->GetResourceId());
154
152 PythonObject args(lock, PyTuple_New(3)); 155 PythonObject args(lock, PyTuple_New(3));
153 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromLong(change->GetChangeType())); 156 PyTuple_SetItem(args.GetPyObject(), 0, PyLong_FromLong(change->GetChangeType()));
154 PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(change->GetResourceType())); 157 PyTuple_SetItem(args.GetPyObject(), 1, PyLong_FromLong(change->GetResourceType()));
155 PyTuple_SetItem(args.GetPyObject(), 2, PyUnicode_FromString(change->GetResourceId().c_str())); 158 PyTuple_SetItem(args.GetPyObject(), 2, resourceId.Release());
159
156 PythonObject result(lock, PyObject_CallObject(changesCallback_, args.GetPyObject())); 160 PythonObject result(lock, PyObject_CallObject(changesCallback_, args.GetPyObject()));
157 161
158 std::string traceback; 162 std::string traceback;
159 if (lock.HasErrorOccurred(traceback)) 163 if (lock.HasErrorOccurred(traceback))
160 { 164 {