Content-Length: 259788 | pFad | http://github.com/postgrespro/postgres/commit/558cf803876874c55d637a1e87417fa1c670efe1

C0 bufmgr: Fix undefined behaviour with, unrealistically, large temp_buf… · postgrespro/postgres@558cf80 · GitHub
Skip to content

Commit 558cf80

Browse files
committed
bufmgr: Fix undefined behaviour with, unrealistically, large temp_buffers
Quoting Melanie: > Since if buffer is INT_MAX, then the -(buffer + 1) version invokes > undefined behavior while the -buffer - 1 version doesn't. All other places were already using the correct version. I (Andres), copied the code into more places in a patch. Melanie caught it in review, but to prevent more people from copying the bad code, fix it. Even if it is a theoretical issue. We really ought to wrap these accesses in a helper function... As this is a theoretical issue, don't backpatch. Reported-by: Melanie Plageman <melanieplageman@gmail.com> Discussion: https://postgr.es/m/CAAKRu_aW2SX_LWtwHgfnqYpBrunMLfE9PD6-ioPpkh92XH0qpg@mail.gmail.com
1 parent e9d202a commit 558cf80

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/storage/buffer/localbuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ MarkLocalBufferDirty(Buffer buffer)
305305
fprintf(stderr, "LB DIRTY %d\n", buffer);
306306
#endif
307307

308-
bufid = -(buffer + 1);
308+
bufid = -buffer - 1;
309309

310310
Assert(LocalRefCount[bufid] > 0);
311311

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/558cf803876874c55d637a1e87417fa1c670efe1

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy