diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-08 18:02:44 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-08 18:02:44 +0100 |
commit | 501eba69140a327913cbbc486238a38feaf0a6f3 (patch) | |
tree | 39d02ff048b3891af159500767982da2ba254ecc /src/loader/loader.nim | |
parent | 761a69376aec86076669e8de7d9c57be4dea3896 (diff) | |
download | chawan-501eba69140a327913cbbc486238a38feaf0a6f3.tar.gz |
loader: fix memory leak
Diffstat (limited to 'src/loader/loader.nim')
-rw-r--r-- | src/loader/loader.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/loader/loader.nim b/src/loader/loader.nim index 71aca5ad..18cd7767 100644 --- a/src/loader/loader.nim +++ b/src/loader/loader.nim @@ -284,8 +284,8 @@ proc runFileLoader*(fd: cint, config: LoaderConfig) = let handle = ctx.handleMap[event.fd] assert event.fd != handle.fd while true: + let buffer = newLoaderBuffer() try: - let buffer = newLoaderBuffer() buffer.len = handle.istream.readData(addr buffer[0], buffer.cap) if buffer.len == 0: dealloc(buffer) @@ -294,8 +294,10 @@ proc runFileLoader*(fd: cint, config: LoaderConfig) = if buffer.len < buffer.cap: break except ErrorAgain, ErrorWouldBlock: # retry later + dealloc(buffer) break except ErrorBrokenPipe: # sender died; stop streaming + dealloc(buffer) unregRead.add(handle) break if Write in event.events: |