Commit cfa350b3 authored by Noel Gordon's avatar Noel Gordon Committed by Commit Bot

[piexwasm] Reset ImageBuffer .memory property on close

On releasing our allocated .memory, reset this.memory back to 0. Minor
closure fix: remove @struct from PixeLoader, since that class does not
have any |this| properties by-design.

Bug: 1132695
No-try: true
Change-Id: Icb2d9f7cf6fcfdb0d89c2dd1c69c89958987fbc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2437316
Commit-Queue: Noel Gordon <noel@chromium.org>
Commit-Queue: Trent Apted <tapted@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Reviewed-by: default avatarAlex Danilo <adanilo@chromium.org>
Auto-Submit: Noel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811958}
parent b7bfb365
...@@ -250,8 +250,8 @@ class ImageBuffer { ...@@ -250,8 +250,8 @@ class ImageBuffer {
/** /**
* Calls Module.image() to process |this.source| and return the result. * Calls Module.image() to process |this.source| and return the result.
* *
* @throws {!Error} Memory allocation error.
* @return {!PiexWasmImageResult} * @return {!PiexWasmImageResult}
* @throws {!Error}
*/ */
process() { process() {
this.memory = PiexModule._malloc(this.length); this.memory = PiexModule._malloc(this.length);
...@@ -474,14 +474,17 @@ class ImageBuffer { ...@@ -474,14 +474,17 @@ class ImageBuffer {
* Release resources. * Release resources.
*/ */
close() { close() {
PiexModule._free(this.memory); const memory = this.memory;
if (memory) {
PiexModule._free(memory);
this.memory = 0;
}
} }
} }
/** /**
* Creates a PiexLoader. * Creates a PiexLoader.
* @constructor * @constructor
* @struct
*/ */
function PiexLoader() {} function PiexLoader() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment