Skip to content

Commit

Permalink
Fix unfreed umka allocations after errors
Browse files Browse the repository at this point in the history
  • Loading branch information
skejeton committed Apr 3, 2024
1 parent ca41a92 commit bb5048b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ th_audio_load(th_sound **out, char *path, uint32_t flags)
if (ma_sound_init_from_file(&thg->audio_engine, path,
MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_NO_SPATIALIZATION | flags, NULL, NULL,
&s->inst) != MA_SUCCESS) {
umkaDecRef(thg->umka, s);
return th_err_io;
}

Expand All @@ -58,6 +59,7 @@ th_sound_copy(th_sound **out, th_sound *s)
if (ma_sound_init_copy(&thg->audio_engine, &s->inst,
MA_SOUND_FLAG_DECODE | MA_SOUND_FLAG_NO_SPATIALIZATION, NULL,
&r->inst) != MA_SUCCESS) {
umkaDecRef(thg->umka, r);
return 1;
}

Expand Down
2 changes: 2 additions & 0 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ th_image_create_render_target(th_render_target **out, int width, int height, int
t->image->smp = sg_make_sampler(&smp_desc);
th_err err = assert_image(t->image);
if (err) {
umkaDecRef(thg->umka, t);
return err;
}

Expand Down Expand Up @@ -204,6 +205,7 @@ th_load_image(th_image **out, char *path)
th_err err = gen_tex(img, (uint32_t *)data);
stbi_image_free(data);
if (err) {
umkaDecRef(thg->umka, img);
return err;
}

Expand Down

0 comments on commit bb5048b

Please sign in to comment.