Skip to content

Commit

Permalink
Merge pull request #28 from kozakura913/master
Browse files Browse the repository at this point in the history
fix WebPPicture memory leak
  • Loading branch information
Jared Forth committed Jul 11, 2023
2 parents 6d83761 + a6b7a83 commit a981a30
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ impl<'a> Encoder<'a> {

pub fn encode_advanced(&self, config: &WebPConfig) -> Result<WebPMemory, WebPEncodingError> {
unsafe {
let picture = new_picture(self.image, self.layout, self.width, self.height);
encode(picture, config)
let mut picture = new_picture(self.image, self.layout, self.width, self.height);
let res = encode(picture, config);
libwebp_sys::WebPPictureFree(&mut picture as *mut _);
res
}
}
}
Expand Down

0 comments on commit a981a30

Please sign in to comment.