mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Merge 33e25d757d into 6e370e06d1
This commit is contained in:
commit
5705c736a1
1 changed files with 9 additions and 1 deletions
|
|
@ -971,8 +971,16 @@ private final class DecompressedData {
|
|||
self.dataRange = dataRange
|
||||
|
||||
self.stream = UnsafeMutablePointer<compression_stream>.allocate(capacity: 1)
|
||||
// Do NOT deallocate self.stream here on failure: since all stored
|
||||
// properties (incl. self.stream) are already assigned at this point,
|
||||
// Swift's ARC still calls deinit on this failed-init instance once
|
||||
// `return nil` executes below — and deinit unconditionally destroys
|
||||
// and deallocates self.stream too. Deallocating it here as well was a
|
||||
// double free (libsystem_malloc "pointer being freed was not
|
||||
// allocated" -> SIGABRT, seen in the field on rare
|
||||
// compression_stream_init failures). Let deinit be the single owner
|
||||
// of that cleanup.
|
||||
guard compression_stream_init(self.stream, COMPRESSION_STREAM_DECODE, algorithm) != COMPRESSION_STATUS_ERROR else {
|
||||
self.stream.deallocate()
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue