Skip to content

Commit 63f97af

Browse files
authored
Merge pull request #82 from ndsl7109256/Fixleak
Fix memory leak when VNC exit
2 parents 3bee378 + ee8a00a commit 63f97af

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

apps/multi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static void apps_flower_start(twin_screen_t *screen, int x, int y, int w, int h)
268268
draw_flower(path, D(3), 5);
269269
twin_paint_path(pixmap, 0xffe2d2d2, path);
270270
twin_path_destroy(stroke);
271+
twin_path_destroy(path);
271272
twin_window_show(window);
272273
}
273274

backend/vnc.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,18 @@ static bool _twin_vnc_work(void *closure)
102102
return true;
103103
}
104104

105+
static void _twin_vnc_client_cleanup(struct nvnc_client *client)
106+
{
107+
twin_peer_t *peer = nvnc_get_userdata(client);
108+
free(peer);
109+
nvnc_set_userdata(client, NULL, NULL);
110+
}
111+
105112
static void _twin_vnc_new_client(struct nvnc_client *client)
106113
{
107114
twin_peer_t *peer = malloc(sizeof(twin_peer_t));
108115
nvnc_set_userdata(client, peer, NULL);
116+
nvnc_set_client_cleanup_fn(client, _twin_vnc_client_cleanup);
109117
}
110118

111119
static void _twin_vnc_pointer_event(struct nvnc_client *client,
@@ -268,11 +276,12 @@ static void twin_vnc_exit(twin_context_t *ctx)
268276
return;
269277

270278
twin_vnc_t *tx = PRIV(ctx);
271-
279+
nvnc_fb_unref(tx->current_fb);
272280
nvnc_display_unref(tx->display);
273281
nvnc_close(tx->server);
274282
aml_unref(tx->aml);
275283

284+
free(tx->framebuffer);
276285
free(ctx->priv);
277286
free(ctx);
278287
}

0 commit comments

Comments
 (0)