Skip to content

Commit 57379cd

Browse files
committed
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/ec64956b-4597-56b6-c3db-457d15250fe4@2ndquadrant.com Backpatch-through: 12
1 parent e3db3f8 commit 57379cd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,6 +1696,8 @@ parse_int_param(const char *value, int *result, PGconn *conn,
16961696
char *end;
16971697
long numval;
16981698

1699+
Assert(value != NULL);
1700+
16991701
*result = 0;
17001702

17011703
/* strtol(3) skips leading whitespaces */
@@ -1713,10 +1715,10 @@ parse_int_param(const char *value, int *result, PGconn *conn,
17131715
* Skip any trailing whitespace; if anything but whitespace remains before
17141716
* the terminating character, fail
17151717
*/
1716-
while (*end && *end != '\0' && isspace((unsigned char) *end))
1718+
while (*end != '\0' && isspace((unsigned char) *end))
17171719
end++;
17181720

1719-
if (*end && *end != '\0')
1721+
if (*end != '\0')
17201722
goto error;
17211723

17221724
*result = numval;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy