From aa8eebdae1bc0846d63244f9bb6f22f341b0c8d1 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Wed, 20 Sep 2023 19:31:54 +0200 Subject: [PATCH] Fix small leak --- submodules/Postbox/Sources/Coding.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/submodules/Postbox/Sources/Coding.swift b/submodules/Postbox/Sources/Coding.swift index 03d5a266ae..bed9fefa57 100644 --- a/submodules/Postbox/Sources/Coding.swift +++ b/submodules/Postbox/Sources/Coding.swift @@ -158,6 +158,9 @@ public final class WriteBuffer: MemoryBuffer { if self.offset + length > self.capacity { self.capacity = self.offset + length + 256 if self.length == 0 { + if self.freeWhenDone { + free(self.memory) + } self.memory = malloc(self.capacity)! } else { self.memory = realloc(self.memory, self.capacity) @@ -173,6 +176,9 @@ public final class WriteBuffer: MemoryBuffer { if self.offset + length > self.capacity { self.capacity = self.offset + length + 256 if self.length == 0 { + if self.freeWhenDone { + free(self.memory) + } self.memory = malloc(self.capacity)! } else { self.memory = realloc(self.memory, self.capacity)