~ruther/guix-local

ref: b989e0138e1684df4d043af813a96fba73dd8c8c guix-local/gnu/packages/patches/renpy-fix-integer-slots.patch -rw-r--r-- 1.4 KiB
b989e013 — Andy Tai gnu: koboldcpp: Update to 1.106.2. 30 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Index: renpy-8.5.0-source/renpy/cslots.pyx
===================================================================
--- renpy-8.5.0-source.orig/renpy/cslots.pyx
+++ renpy-8.5.0-source/renpy/cslots.pyx
@@ -32,6 +32,9 @@ Value unions, followed by a series of by
 from cpython.mem cimport PyMem_Calloc, PyMem_Free
 from cpython.object cimport PyObject, PyTypeObject, Py_TPFLAGS_HAVE_GC, PyObject_Free
 from cpython.ref cimport Py_XINCREF, Py_XDECREF, Py_CLEAR
+cdef extern from "<limits.h>":
+    const long long LLONG_MIN
+    const long long LLONG_MAX
 
 from copyreg import __newobj__
 
@@ -51,7 +54,7 @@ cdef unsigned char DEFAULT_VALUE = 0xff
 
 cdef union Value:
     PyObject *object
-    unsigned long long integer
+    long long integer
 
 cdef class CMetaclass(type):
 
@@ -369,10 +372,15 @@ cdef class IntegerSlot(Slot):
         super(IntegerSlot, self).__init__(default_value)
         self.default_int_value = default_value
 
-    def __set__(self, CObject instance, unsigned int value):
+    def __set__(self, CObject instance, long long value):
 
         cdef Value v
 
+        if value >= (LLONG_MAX >> 1):
+           raise OverflowError("Value is too large for an IntegerSlot")
+        if value <= (LLONG_MIN >> 1):
+           raise OverflowError("Value is too small for an IntegerSlot")
+
         if value == self.default_int_value:
             v.object = NULL
         else: