From: Daniele Varrazzo Date: Fri, 25 Nov 2022 14:48:05 +0000 (+0100) Subject: fix(c/array): null-terminate strings in text array loading X-Git-Tag: 3.1.5~12^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e243c4c91b79ee385a3715dd1e2cb428d91318f2;p=thirdparty%2Fpsycopg.git fix(c/array): null-terminate strings in text array loading --- diff --git a/psycopg_c/psycopg_c/types/array.pyx b/psycopg_c/psycopg_c/types/array.pyx index b42d76035..9019d0736 100644 --- a/psycopg_c/psycopg_c/types/array.pyx +++ b/psycopg_c/psycopg_c/types/array.pyx @@ -142,7 +142,7 @@ cdef object parse_token( return load(b) else: - unesc = PyMem_Malloc(length - num_escapes) + unesc = PyMem_Malloc(length - num_escapes + 1) src = start tgt = unesc while src < end: @@ -152,6 +152,8 @@ cdef object parse_token( src += 1 tgt += 1 + tgt[0] = b'\x00' + try: if cloader is not None: return cloader.cload(unesc, length - num_escapes)