Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak in _emscripten_set_offscreencanvas_size_on_thread #23275

Merged
merged 4 commits into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading