[tests] Fix BitmapContextTest.CreateAdaptive_3/_4 crash due to undersized buffer#24920
[tests] Fix BitmapContextTest.CreateAdaptive_3/_4 crash due to undersized buffer#24920rolfbjarne merged 2 commits intomainfrom
Conversation
…ized buffer CreateAdaptive_3 and CreateAdaptive_4 used a hardcoded 512-byte buffer for a 256x256 adaptive bitmap context. When ToImage() called CGBitmapContextCreateImage, CoreGraphics tried to copy the bitmap data from this tiny buffer, reading past the allocation and causing a SIGSEGV. Fix CreateAdaptive_3 by computing the buffer size from parameters.AlignedBytesPerRow * parameters.Height (matching CreateAdaptive_2). Fix CreateAdaptive_4 by using a 1MB buffer, large enough for any 256x256 adaptive bitmap format. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a crash in CoreGraphics adaptive bitmap context tests caused by providing an undersized rendering buffer to CGBitmapContext and then calling ToImage() (which triggers CGBitmapContextCreateImage to read the full backing store).
Changes:
CreateAdaptive_3: compute the buffer size fromparameters.AlignedBytesPerRow * parameters.Height(matching the existingCreateAdaptive_2pattern).CreateAdaptive_4: increase the preallocated buffer from 512 bytes to 1MB to avoid out-of-bounds reads during image creation.
You can also share your feedback on Copilot code review. Take the survey.
…coding Address review feedback: replace the hardcoded 1MB buffer with a properly computed size from parameters.AlignedBytesPerRow * parameters.Height in OnAllocate, matching the pattern used in CreateAdaptive_2 and _3. The buffer provider is now created inside OnAllocate and stored in an outer-scope variable so it can be explicitly disposed afterward to verify the releaseInfo callback is called. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #0511a9d] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #0511a9d] Build passed (Detect API changes) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #0511a9d] Build passed (Build macOS tests) ✅Pipeline on Agent |
🚀 [CI Build #0511a9d] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 156 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download macOS tests✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
…ized buffer (#24920) CreateAdaptive_3 and CreateAdaptive_4 used a hardcoded 512-byte buffer for a 256x256 adaptive bitmap context. When ToImage() called CGBitmapContextCreateImage, CoreGraphics tried to copy the bitmap data from this tiny buffer, reading past the allocation and causing a SIGSEGV. Fix CreateAdaptive_3 by computing the buffer size from parameters.AlignedBytesPerRow * parameters.Height (matching CreateAdaptive_2). Fix CreateAdaptive_4 by using a 1MB buffer, large enough for any 256x256 adaptive bitmap format. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ized buffer (#24920) CreateAdaptive_3 and CreateAdaptive_4 used a hardcoded 512-byte buffer for a 256x256 adaptive bitmap context. When ToImage() called CGBitmapContextCreateImage, CoreGraphics tried to copy the bitmap data from this tiny buffer, reading past the allocation and causing a SIGSEGV. Fix CreateAdaptive_3 by computing the buffer size from parameters.AlignedBytesPerRow * parameters.Height (matching CreateAdaptive_2). Fix CreateAdaptive_4 by using a 1MB buffer, large enough for any 256x256 adaptive bitmap format. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
CreateAdaptive_3 and CreateAdaptive_4 used a hardcoded 512-byte buffer for
a 256x256 adaptive bitmap context. When ToImage() called
CGBitmapContextCreateImage, CoreGraphics tried to copy the bitmap data from
this tiny buffer, reading past the allocation and causing a SIGSEGV.
Fix CreateAdaptive_3 by computing the buffer size from
parameters.AlignedBytesPerRow * parameters.Height (matching CreateAdaptive_2).
Fix CreateAdaptive_4 by using a 1MB buffer, large enough for any 256x256
adaptive bitmap format.