- Notifications
You must be signed in to change notification settings - Fork4.9k
Commitac3afd1
committed
Fix AlignedAllocRealloc to cope sanely with OOM.
If the inner allocation call returns NULL, we should restore theprevious state and return NULL. Previously this code pfree'dthe old chunk anyway, which is surely wrong.Also, make it call MemoryContextAllocationFailure rather thansummarily returning NULL. The fact that we got control back from theinner call proves that MCXT_ALLOC_NO_OOM was passed, so this changeis just cosmetic, but someday it might be less so.This is just a latent bug at present: AFAICT no in-core callers usethis function at all, let alone call it with MCXT_ALLOC_NO_OOM.Still, it's the kind of bug that might bite back-patched code prettyhard someday, so let's back-patch to v17 where the bug was introduced(by commit743112a).Author: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/285483.1746756246@sss.pgh.pa.usBackpatch-through: 171 parent20bae06 commitac3afd1
1 file changed
+22
-7
lines changedLines changed: 22 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
45 | 45 |
| |
46 | 46 |
| |
47 | 47 |
| |
| 48 | + | |
48 | 49 |
| |
49 | 50 |
| |
50 | 51 |
| |
| |||
96 | 97 |
| |
97 | 98 |
| |
98 | 99 |
| |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
99 | 106 |
| |
100 | 107 |
| |
101 | 108 |
| |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
| 109 | + | |
| 110 | + | |
107 | 111 |
| |
108 |
| - | |
109 |
| - | |
| 112 | + | |
| 113 | + | |
110 | 114 |
| |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
111 | 126 |
| |
112 | 127 |
| |
113 | 128 |
| |
|
0 commit comments
Comments
(0)