Skip to content

Commit a981a30

Browse files
author
Jared Forth
authored
Merge pull request #28 from kozakura913/master
fix WebPPicture memory leak
2 parents 6d83761 + a6b7a83 commit a981a30

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/encoder.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ impl<'a> Encoder<'a> {
9292

9393
pub fn encode_advanced(&self, config: &WebPConfig) -> Result<WebPMemory, WebPEncodingError> {
9494
unsafe {
95-
let picture = new_picture(self.image, self.layout, self.width, self.height);
96-
encode(picture, config)
95+
let mut picture = new_picture(self.image, self.layout, self.width, self.height);
96+
let res = encode(picture, config);
97+
libwebp_sys::WebPPictureFree(&mut picture as *mut _);
98+
res
9799
}
98100
}
99101
}

0 commit comments

Comments
 (0)