From: jerch Date: Sat, 6 Sep 2025 14:47:31 +0000 (+0200) Subject: fix: fix excessive buffer resizing on int16 dump X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=90f1834262255ddd0975aadee63e6343691619d1;p=thirdparty%2Fpsycopg.git fix: fix excessive buffer resizing on int16 dump Fix #1160 --- diff --git a/psycopg_c/psycopg_c/types/numeric.pyx b/psycopg_c/psycopg_c/types/numeric.pyx index 24fd0c4ad..d807302f9 100644 --- a/psycopg_c/psycopg_c/types/numeric.pyx +++ b/psycopg_c/psycopg_c/types/numeric.pyx @@ -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 = PyLong_AsLongLong(obj) - cdef int16_t *buf = CDumper.ensure_size(rv, offset, sizeof(obj)) + cdef int16_t *buf = 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)