Fix small leak

This commit is contained in:
Ali
2023-09-20 19:31:54 +02:00
parent e7093ac39e
commit aa8eebdae1

View File

@@ -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)