]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix: fix excessive buffer resizing on int16 dump
authorjerch <jerch@rockborn.de>
Sat, 6 Sep 2025 14:47:31 +0000 (16:47 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 6 Sep 2025 17:10:02 +0000 (19:10 +0200)
Fix #1160

psycopg_c/psycopg_c/types/numeric.pyx

index 24fd0c4ad9ea147fcc65537a71b39eda42d83d6c..d807302f97bcae7de7365e96ae9a65957724e5ad 100644 (file)
@@ -758,7 +758,7 @@ cdef Py_ssize_t dump_int_to_int2_binary(
     obj, bytearray rv, Py_ssize_t offset
 ) except -1:
     cdef int16_t val = <int16_t>PyLong_AsLongLong(obj)
-    cdef int16_t *buf = <int16_t *>CDumper.ensure_size(rv, offset, sizeof(obj))
+    cdef int16_t *buf = <int16_t *>CDumper.ensure_size(rv, offset, sizeof(val))
     cdef uint16_t beval = endian.htobe16(val)  # swap bytes if needed
     memcpy(buf, &beval, sizeof(beval))
     return sizeof(val)