From 27b26bc210f7f4e17dd9a574d9c8c477acbf5763 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Wed, 23 Jan 2019 09:30:05 +0000 Subject: [PATCH] Fixed apparent access to uninitialized var No error before: cpychecker is confused but the var was init'd by PyLong_FromString. davidmalcolm/gcc-python-plugin#167 --- psycopg/typecast_datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/psycopg/typecast_datetime.c b/psycopg/typecast_datetime.c index e34117dd..8940942a 100644 --- a/psycopg/typecast_datetime.c +++ b/psycopg/typecast_datetime.c @@ -286,7 +286,7 @@ static PyObject * interval_from_usecs(const char *str) { PyObject *us = NULL; - char *pend; + char *pend = NULL; PyObject *rv = NULL; Dprintf("interval_from_usecs: %s", str); @@ -296,7 +296,7 @@ interval_from_usecs(const char *str) goto exit; } - if (*pend != '\0') { + if (pend && *pend != '\0') { /* there are trailing chars, it's not just micros. Barf. */ Dprintf("interval_from_usecs: spurious chars %s", pend); PyErr_Format(PyExc_ValueError,