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

[Bug Fix] Segfaults/UB when deleting images with 2 or more instances #30

Merged
merged 2 commits into from
May 16, 2022
Merged

[Bug Fix] Segfaults/UB when deleting images with 2 or more instances #30

merged 2 commits into from
May 16, 2022

Conversation

pajotg
Copy link

@pajotg pajotg commented May 15, 2022

When trying to delete a image with 2 or more instances it would only delete the first draw queue element, causing segfaults and other weird things when trying to render the leftover draw queue the next frame

The simplest way to reproduce this segfault would be to compile & run this code:

void hook(void* param)
{
	mlx_t *mlx = param;

	mlx_image_t* g_img = mlx_new_image(mlx, 128, 128);
	mlx_image_to_window(mlx, g_img, 0, 0);
	mlx_image_to_window(mlx, g_img, 0, 0);
	mlx_delete_image(mlx, g_img);
}

int main()
{
	mlx_t* mlx = mlx_init(512, 512, "Segfault Test", true);

	mlx_loop_hook(mlx, &hook, mlx);
	mlx_loop(mlx);
}

Apparently my editor automatically removed spaces at the end of lines, so i guess thats in there too

…ead of only the first one, that was causing segfaults and other odd behaviour when deleting a image with 2 or more instances
@W2Wizard W2Wizard added the Bug Something isn't working or should get fixed label May 16, 2022
@W2Wizard
Copy link
Collaborator

Oof! Thanks for spotting this one! 👍

@W2Wizard W2Wizard merged commit 2418d26 into codam-coding-college:master May 16, 2022
@pajotg pajotg deleted the fix_delete_instances branch May 16, 2022 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working or should get fixed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants