8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b196b7f commit 9f3bd29Copy full SHA for 9f3bd29
contrib/txid/txid.c
@@ -234,24 +234,27 @@ static txid
234
str2txid(const char *s, const char **endp)
235
{
236
txid val = 0;
237
+ txid cutoff = MAX_TXID / 10;
238
+ txid cutlim = MAX_TXID % 10;
239
240
for (; *s; s++)
241
- txid last = val;
242
+ unsigned d;
243
244
if (*s < '0' || *s > '9')
245
break;
-
- val = val * 10 + (*s - '0');
246
+ d = *s - '0';
247
248
/*
249
* check for overflow
250
*/
- if (val > MAX_TXID || (val / 10) != last)
251
+ if (val > cutoff || (val == cutoff && d > cutlim))
252
253
val = 0;
254
255
}
256
+
257
+ val = val * 10 + d;
258
259
if (endp)
260
*endp = s;
0 commit comments