Skip to content

Source Generated RegEx - #24

Merged
love-linger merged 1 commit into
sourcegit-org:masterfrom
ennerperez:feature/regex
Mar 18, 2024
Merged

love-linger merged 1 commit into
sourcegit-org:masterfrom
ennerperez:feature/regex

Conversation

@ennerperez

Copy link
Copy Markdown
Contributor

RegEx changed to Source Generated to improve perfomance:

image

@love-linger
love-linger merged commit a8eeea4 into sourcegit-org:master Mar 18, 2024
@love-linger

Copy link
Copy Markdown
Collaborator

Very nice PR!!!

1llum1n4t1s pushed a commit to 1llum1n4t1s/Komorebi that referenced this pull request May 16, 2026
#5 sourcegit-org#24)

## #5 GCHandle.Alloc(Pinned) で配列を明示的に pin (P0)
DecodeWithStbImage / DecodeWithPfim の両方で Marshal.UnsafeAddrOfPinnedArrayElement を
使っていたが、MSDN 明記の通り **このメソッドは pin しない**。GC が配列を移動した直後に
Bitmap ctor が古いアドレスを参照すると AccessViolationException (AV) のリスク。
GCHandle.Alloc(data, GCHandleType.Pinned) で明示的に pin → try/finally で Free() を保証。
Avalonia Bitmap ctor が同期コピーするので Free 後にアクセスされる経路はない (現状は動作するが
API 契約違反だったため将来の .NET ランタイム最適化変更でサイレントに壊れる経路を遮断)。

## sourcegit-org#24 DecodeWithPfim / DecodeWithTiff の int オーバーフローガード (P1)
悪意 TGA/DDS/TIFF ヘッダで `width * 4` や `width * height` の int オーバーフローが起きて
負値 stride で AV、または極小配列確保後の範囲外書き込みでメモリ破壊する経路を遮断。
DecodeWithStbImage は前回 /rere P0#4 で既にガード追加済 (対称化)。
- Pfim: `width * 4 > int.MaxValue` または `width * height * 4 > 1GB` で弾く
- Tiff: `width * height > 256M` (1GB / 4byte) で弾く
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants