Skip to content

Commit a6a95d4

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 399b8d1 commit a6a95d4

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
@@ -1663,6 +1663,8 @@ parse_int_param(const char *value, int *result, PGconn *conn,
16631663
char *end;
16641664
long numval;
16651665

1666+
Assert(value != NULL);
1667+
16661668
*result = 0;
16671669

16681670
/* strtol(3) skips leading whitespaces */
@@ -1680,10 +1682,10 @@ parse_int_param(const char *value, int *result, PGconn *conn,
16801682
* Skip any trailing whitespace; if anything but whitespace remains before
16811683
* the terminating character, fail
16821684
*/
1683-
while (*end && *end != '\0' && isspace((unsigned char) *end))
1685+
while (*end != '\0' && isspace((unsigned char) *end))
16841686
end++;
16851687

1686-
if (*end && *end != '\0')
1688+
if (*end != '\0')
16871689
goto error;
16881690

16891691
*result = numval;

0 commit comments

Comments
 (0)