Skip to content

Commit

Permalink
Fix memory leak in _emscripten_set_offscreencanvas_size_on_thread (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ypujante authored Jan 2, 2025
1 parent 537d805 commit 89c42b2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion system/lib/html5/offscreencanvas.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ typedef struct set_cavas_size_t {
static void do_set_size(void* arg) {
set_cavas_size_t* args = (set_cavas_size_t*)arg;
_emscripten_set_offscreencanvas_size(args->target, args->width, args->height);
free((char *) args->target);
free(arg);
}

// This function takes ownership of the "target" string.
void _emscripten_set_offscreencanvas_size_on_thread(pthread_t t,
const char* target,
int width,
int height) {
set_cavas_size_t* arg = malloc(sizeof(set_cavas_size_t));
arg->target = target;
arg->target = target; // taking ownership: will be freed in do_set_size
arg->width = width;
arg->height = height;

Expand Down

0 comments on commit 89c42b2

Please sign in to comment.