mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
DecompressedData.init derives src_ptr/src_size from a Data.withUnsafeBytes closure and stashes it into stream.pointee for later use across many read(bytes:count:) calls. Data's documentation is explicit that the pointer handed to withUnsafeBytes is only valid for the duration of that closure — Data's backing storage can move or be deallocated once it returns, leaving src_ptr dangling for every read() call after init. compression_stream_process then reads through that dangling pointer, corrupting the heap; malloc's own consistency checks catch the corruption later and abort() (confirmed on-device: SIGABRT inside libsystem_malloc.dylib, queue DCTMultiAnimationRenderer-FirstFrame, build 33196, ~40s after launch — loading the first frame of an animated sticker/emoji). Re-derive a live pointer inside a fresh withUnsafeBytes call on every read(), tracking how many source bytes compression_stream_process has already consumed (consumedSrcBytes) so each call resumes from the right offset. compression_stream_process's own src_size/dst_size bookkeeping is unchanged; only the pointer's lifetime handling is fixed. |
||
|---|---|---|
| .. | ||
| Sources | ||
| BUILD | ||