diff options
author | Michael Paquier | 2019-10-23 02:34:18 +0000 |
---|---|---|
committer | Michael Paquier | 2019-10-23 02:34:18 +0000 |
commit | 57379cd5ac56e575630a5fee5777a1035d0a764a (patch) | |
tree | b8d8e95a4ab8ad3417d035da6519bd2d590b7b23 /src | |
parent | e3db3f829f605edc0675e5d308de97f444b53d4b (diff) |
Fix thinkos from 4f4061b for libpq integer parsing
A check was redundant. While on it, add an assertion to make sure that
the parsing routine is never called with a NULL input. All the code
paths currently calling the parsing routine are careful with NULL inputs
already, but future callers may forget that.
Reported-by: Peter Eisentraut, Lars Kanis
Discussion: https://postgr.es/m/[email protected]
Backpatch-through: 12
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/fe-connect.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 9af830321c3..99051231a6e 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -1696,6 +1696,8 @@ parse_int_param(const char *value, int *result, PGconn *conn, char *end; long numval; + Assert(value != NULL); + *result = 0; /* strtol(3) skips leading whitespaces */ @@ -1713,10 +1715,10 @@ parse_int_param(const char *value, int *result, PGconn *conn, * Skip any trailing whitespace; if anything but whitespace remains before * the terminating character, fail */ - while (*end && *end != '\0' && isspace((unsigned char) *end)) + while (*end != '\0' && isspace((unsigned char) *end)) end++; - if (*end && *end != '\0') + if (*end != '\0') goto error; *result = numval; |