- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit4ed6dc7
committed
Set snprintf.c's maximum number of NL arguments to be 31.
Previously, we used the platform's NL_ARGMAX if any, otherwise 16.The trouble with this is that the platform value is hugely variable,ranging from the POSIX-minimum 9 to as much as 64K on recent FreeBSD.Values of more than a dozen or two have no practical use and slow downthe initialization of the argtypes array. Worse, they cause snprintf.cto consume far more stack space than was the design intention, possiblyresulting in stack-overflow crashes.Standardize on 31, which is comfortably more than we need (it looks likeno existing translatable message has more than about 10 parameters).I chose that, not 32, to make the array sizes powers of 2, for somepossible small gain in speed of the memset.The lack of reported crashes suggests that the set of platforms weuse snprintf.c on (in released branches) may have no overlap withthe set where NL_ARGMAX has unreasonably large values. But that'snot entirely clear, so back-patch to all supported branches.Per report from Mateusz Guzik (via Thomas Munro).Discussion:https://postgr.es/m/CAEepm=3VF=PUp2f8gU8fgZB22yPE_KBS0+e1AHAtQ=09schTHg@mail.gmail.com1 parent01c7a87 commit4ed6dc7
1 file changed
+10
-6
lines changedLines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
47 |
| - | |
48 |
| - | |
49 |
| - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
50 | 54 |
| |
51 | 55 |
| |
52 | 56 |
| |
| |||
345 | 349 |
| |
346 | 350 |
| |
347 | 351 |
| |
348 |
| - | |
349 |
| - | |
| 352 | + | |
| 353 | + | |
350 | 354 |
| |
351 | 355 |
| |
352 | 356 |
| |
| |||
396 | 400 |
| |
397 | 401 |
| |
398 | 402 |
| |
399 |
| - | |
| 403 | + | |
400 | 404 |
| |
401 | 405 |
| |
402 | 406 |
| |
|
0 commit comments
Comments
(0)