forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit6217053
committed
Avoid ERRCODE_INTERNAL_ERROR in oracle_compat.c functions.
repeat() checked for integer overflow during its calculation of therequired output space, but it just passed the resulting integer topalloc(). This meant that result sizes between 1GB and 2GB led toERRCODE_INTERNAL_ERROR, "invalid memory alloc request size" ratherthan ERRCODE_PROGRAM_LIMIT_EXCEEDED, "requested length too large".That seems like a bit of a wart, so add an explicit AllocSizeIsValidcheck to make these error cases uniform.Do likewise in the sibling functions lpad() etc. While we're here,also modernize their overflow checks to use pg_mul_s32_overflow() etcinstead of expensive divisions.Per complaint from Japin Li. This is basically cosmetic, so I don'tfeel a need to back-patch.Discussion:https://postgr.es/m/ME3P282MB16676ED32167189CB0462173B6D69@ME3P282MB1667.AUSP282.PROD.OUTLOOK.COM1 parentde89d87 commit6217053
1 file changed
+24
-19
lines changedLines changed: 24 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
20 | 20 |
| |
21 | 21 |
| |
22 | 22 |
| |
| 23 | + | |
| 24 | + | |
23 | 25 |
| |
24 | 26 |
| |
25 | 27 |
| |
| |||
155 | 157 |
| |
156 | 158 |
| |
157 | 159 |
| |
158 |
| - | |
159 | 160 |
| |
160 | 161 |
| |
161 | 162 |
| |
| |||
178 | 179 |
| |
179 | 180 |
| |
180 | 181 |
| |
181 |
| - | |
182 |
| - | |
183 |
| - | |
184 |
| - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
185 | 187 |
| |
186 | 188 |
| |
187 | 189 |
| |
188 | 190 |
| |
189 |
| - | |
| 191 | + | |
190 | 192 |
| |
191 | 193 |
| |
192 | 194 |
| |
| |||
253 | 255 |
| |
254 | 256 |
| |
255 | 257 |
| |
256 |
| - | |
257 | 258 |
| |
258 | 259 |
| |
259 | 260 |
| |
| |||
276 | 277 |
| |
277 | 278 |
| |
278 | 279 |
| |
279 |
| - | |
280 |
| - | |
281 |
| - | |
282 |
| - | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
283 | 285 |
| |
284 | 286 |
| |
285 | 287 |
| |
286 | 288 |
| |
287 |
| - | |
| 289 | + | |
| 290 | + | |
288 | 291 |
| |
289 | 292 |
| |
290 | 293 |
| |
| |||
805 | 808 |
| |
806 | 809 |
| |
807 | 810 |
| |
808 |
| - | |
| 811 | + | |
809 | 812 |
| |
810 | 813 |
| |
811 | 814 |
| |
| |||
824 | 827 |
| |
825 | 828 |
| |
826 | 829 |
| |
827 |
| - | |
828 |
| - | |
829 |
| - | |
830 |
| - | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
831 | 834 |
| |
832 | 835 |
| |
833 | 836 |
| |
834 | 837 |
| |
835 |
| - | |
| 838 | + | |
| 839 | + | |
836 | 840 |
| |
837 | 841 |
| |
838 | 842 |
| |
| |||
1128 | 1132 |
| |
1129 | 1133 |
| |
1130 | 1134 |
| |
1131 |
| - | |
| 1135 | + | |
| 1136 | + | |
1132 | 1137 |
| |
1133 | 1138 |
| |
1134 | 1139 |
| |
|
0 commit comments
Comments
(0)