- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit09ac603
committed
Work around unportable behavior of malloc(0) and realloc(NULL, 0).
On some platforms these functions return NULL, rather than the more commonpractice of returning a pointer to a zero-sized block of memory. Hack ourvarious wrapper functions to hide the difference by substituting a sizerequest of 1. This is probably not so important for the callers, whoshould never touch the block anyway if they asked for size 0 --- but it'simportant for the wrapper functions themselves, which mistakenly treatedthe NULL result as an out-of-memory failure. This broke at least pg_dumpfor the case of no user-defined aggregates, as per report fromMatthew Carrington.Back-patch to 9.2 to fix the pg_dump issue. Given the lack of previouscomplaints, it seems likely that there is no live bug in previous releases,even though some of these functions were in place before that.1 parent2164f9a commit09ac603
11 files changed
+85
-22
lines changedLines changed: 27 additions & 11 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| 54 | + | |
54 | 55 |
| |
55 | 56 |
| |
56 | 57 |
| |
| |||
203 | 204 |
| |
204 | 205 |
| |
205 | 206 |
| |
206 |
| - | |
| 207 | + | |
207 | 208 |
| |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 |
| |
209 | 214 |
| |
210 |
| - | |
| 215 | + | |
211 | 216 |
| |
212 | 217 |
| |
213 | 218 |
| |
214 | 219 |
| |
215 | 220 |
| |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
216 | 238 |
| |
217 | 239 |
| |
218 | 240 |
| |
219 | 241 |
| |
220 | 242 |
| |
221 | 243 |
| |
222 | 244 |
| |
223 |
| - | |
| 245 | + | |
224 | 246 |
| |
225 | 247 |
| |
226 | 248 |
| |
| |||
242 | 264 |
| |
243 | 265 |
| |
244 | 266 |
| |
245 |
| - | |
246 |
| - | |
247 |
| - | |
248 |
| - | |
249 |
| - | |
250 |
| - | |
251 |
| - | |
252 |
| - | |
| 267 | + | |
| 268 | + | |
253 | 269 |
| |
254 | 270 |
| |
255 | 271 |
| |
|
Lines changed: 15 additions & 9 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
192 | 192 |
| |
193 | 193 |
| |
194 | 194 |
| |
195 |
| - | |
| 195 | + | |
196 | 196 |
| |
197 |
| - | |
| 197 | + | |
198 | 198 |
| |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
199 | 203 |
| |
200 | 204 |
| |
201 |
| - | |
202 | 205 |
| |
203 | 206 |
| |
204 | 207 |
| |
205 | 208 |
| |
206 |
| - | |
| 209 | + | |
207 | 210 |
| |
208 |
| - | |
| 211 | + | |
209 | 212 |
| |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
210 | 217 |
| |
211 | 218 |
| |
212 |
| - | |
213 | 219 |
| |
214 | 220 |
| |
215 | 221 |
| |
216 | 222 |
| |
217 | 223 |
| |
218 |
| - | |
| 224 | + | |
219 | 225 |
| |
220 |
| - | |
221 |
| - | |
| 226 | + | |
| 227 | + | |
222 | 228 |
| |
223 | 229 |
| |
224 | 230 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
299 | 299 |
| |
300 | 300 |
| |
301 | 301 |
| |
| 302 | + | |
| 303 | + | |
| 304 | + | |
302 | 305 |
| |
303 | 306 |
| |
304 | 307 |
| |
| |||
313 | 316 |
| |
314 | 317 |
| |
315 | 318 |
| |
| 319 | + | |
| 320 | + | |
| 321 | + | |
316 | 322 |
| |
317 | 323 |
| |
318 | 324 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3358 | 3358 |
| |
3359 | 3359 |
| |
3360 | 3360 |
| |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
3361 | 3364 |
| |
3362 | 3365 |
| |
3363 | 3366 |
| |
| |||
3371 | 3374 |
| |
3372 | 3375 |
| |
3373 | 3376 |
| |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
3374 | 3380 |
| |
3375 | 3381 |
| |
3376 | 3382 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
| 297 | + | |
| 298 | + | |
| 299 | + | |
297 | 300 |
| |
298 | 301 |
| |
299 | 302 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
54 | 54 |
| |
55 | 55 |
| |
56 | 56 |
| |
| 57 | + | |
| 58 | + | |
| 59 | + | |
57 | 60 |
| |
58 | 61 |
| |
59 | 62 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
233 | 233 |
| |
234 | 234 |
| |
235 | 235 |
| |
| 236 | + | |
| 237 | + | |
| 238 | + | |
236 | 239 |
| |
237 | 240 |
| |
238 | 241 |
| |
|
Lines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
| 45 | + | |
| 46 | + | |
| 47 | + | |
45 | 48 |
| |
46 | 49 |
| |
47 | 50 |
| |
| |||
63 | 66 |
| |
64 | 67 |
| |
65 | 68 |
| |
| 69 | + | |
| 70 | + | |
| 71 | + | |
66 | 72 |
| |
67 | 73 |
| |
68 | 74 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 |
| |
64 | 67 |
| |
65 | 68 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
304 | 304 |
| |
305 | 305 |
| |
306 | 306 |
| |
| 307 | + | |
| 308 | + | |
| 309 | + | |
307 | 310 |
| |
308 | 311 |
| |
309 | 312 |
| |
|
Lines changed: 10 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
73 |
| - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
74 | 78 |
| |
75 | 79 |
| |
76 | 80 |
| |
| |||
96 | 100 |
| |
97 | 101 |
| |
98 | 102 |
| |
99 |
| - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
100 | 108 |
| |
101 | 109 |
| |
102 | 110 |
| |
|
0 commit comments
Comments
(0)