forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit49e29cb
committed
Fix incorrect sentinel byte logic in GenerationRealloc()
This only affects MEMORY_CONTEXT_CHECKING builds.This fixes an off-by-one issue in GenerationRealloc() where thefast-path code which tries to reuse the existing allocation if theexisting chunk is >= the new requested size. The code there thought itwas always ok to use the existing chunk, but when oldsize == size thereisn't enough space to store the sentinel byte. If both sizes matchedexactly set_sentinel() would overwrite the first byte beyond the chunkand then subsequent GenerationRealloc() calls could then fail theAssert(chunk->requested_size < oldsize) check which is trying to ensurethe chunk is large enough to store the sentinel.The same issue does not exist in aset.c as the sentinel checking codeonly adds a sentinel byte if there's enough space in the chunk.Reported-by: Alexander Lakhin <exclusion@gmail.com>Discussion:https://postgr.es/m/49275921-7b39-41af-5eb8-97b50ce3312e@gmail.comBackpatch-through: 16, where the problem was introduced by0e480381 parent31423bc commit49e29cb
1 file changed
+7
-2
lines changedLines changed: 7 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
780 | 780 |
| |
781 | 781 |
| |
782 | 782 |
| |
783 |
| - | |
784 |
| - | |
| 783 | + | |
| 784 | + | |
785 | 785 |
| |
786 | 786 |
| |
787 | 787 |
| |
788 | 788 |
| |
789 | 789 |
| |
790 | 790 |
| |
791 | 791 |
| |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
792 | 796 |
| |
| 797 | + | |
793 | 798 |
| |
794 | 799 |
| |
795 | 800 |
| |
|
0 commit comments
Comments
(0)