forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5c9d17e
committed
Fix bogus casting in BlockIdGetBlockNumber().
This macro cast the result to BlockNumber after shifting, not before,which is the wrong thing. Per the C spec, the uint16 fields wouldpromote to int not unsigned int, so that (for 32-bit int) the shiftpotentially shifts a nonzero bit into the sign position. I doubtthere are any production systems where this would actually end withthe wrong answer, but it is undefined behavior per the C spec, andclang's -fsanitize=undefined option reputedly warns about it on someplatforms. (I can't reproduce that right now, but the code isundeniably wrong per spec.) It's easy to fix by casting toBlockNumber (uint32) in the proper places.It's been wrong for ages, so back-patch to all supported branches.Report and patch by Zhihong Yu (cosmetic tweaking by me)Discussion:https://postgr.es/m/CALNJ-vT9r0DSsAOw9OXVJFxLENoVS_68kJ5x0p44atoYH+H4dg@mail.gmail.com1 parentb0bc196 commit5c9d17e
1 file changed
+1
-1
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
115 | 115 |
| |
116 | 116 |
| |
117 | 117 |
| |
118 |
| - | |
| 118 | + | |
119 | 119 |
| |
120 | 120 |
| |
121 | 121 |
|
0 commit comments
Comments
(0)