From 48e24e8b760a8a01ef02a4a3026a16a9bb8e5b38 Mon Sep 17 00:00:00 2001 From: zcl Date: Thu, 18 Jul 2024 15:55:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BD=93=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E5=90=8E=E5=8F=B0=E6=9F=A5=E8=AF=A2=E4=B8=8D=E5=88=B0?= =?UTF-8?q?uint1=E3=80=81uint2=E3=80=81uint4=E3=80=81uint8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E7=9A=84oid=E5=AF=BC=E8=87=B4=E9=A9=B1=E5=8A=A8?= =?UTF-8?q?=E6=8C=82=E6=8E=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit de9de1acc92ea861875c96367132651c8420e26e) 静态检查 codecheck2 --- psycopg/pqpath.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/psycopg/pqpath.c b/psycopg/pqpath.c index 03fc0c0..7ab56cb 100644 --- a/psycopg/pqpath.c +++ b/psycopg/pqpath.c @@ -616,7 +616,7 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT char query[256]; int size; unsigned int rv = 0; - + char *temp_oid = NULL; size = PyOS_snprintf(query, sizeof(query), "select oid from pg_type where typnamespace = 11 and typname= %s", param); if (size < 0 || (size_t)size >= sizeof(query)) { conn_set_error(conn, "query too large"); @@ -645,8 +645,10 @@ pq_get_pg_catalog_custom_type_oid(connectionObject *conn, const char *param, PyT PQresStatus(PQresultStatus(conn->pgres))); goto cleanup; } - - rv = atoi(strdup(PQgetvalue(conn->pgres, 0, 0))); + temp_oid = PQgetvalue(conn->pgres, 0, 0); + if (temp_oid) { + rv = (unsigned int)atoi(temp_oid); + } CLEARPGRES(conn->pgres); cleanup: