Skip to content

Commit c88e815

Browse files
irisjaeYour Name
authored andcommitted
Set errno to 0 before strtol
Refer to https://man7.org/linux/man-pages/man3/strtol.3.html Fixes cases where calls to the PL/pgSQL functions http_set_curlopt() and http() keep failing after errno is set
1 parent 032617b commit c88e815

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

http.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,9 @@ set_curlopt(CURL* handle, const http_curlopt *opt)
786786
/* Argument is a long */
787787
else if (opt->curlopt_type == CURLOPT_LONG)
788788
{
789-
long value_long = strtol(opt->curlopt_val, NULL, 10);
789+
long value_long;
790+
errno = 0;
791+
value_long = strtol(opt->curlopt_val, NULL, 10);
790792
if ( errno == EINVAL || errno == ERANGE )
791793
elog(ERROR, "invalid integer provided for '%s'", opt->curlopt_str);
792794

0 commit comments

Comments
 (0)