Skip to content

Instantly share code, notes, and snippets.

@lucab
Created April 17, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucab/df6156544dd4e51f1364 to your computer and use it in GitHub Desktop.
Save lucab/df6156544dd4e51f1364 to your computer and use it in GitHub Desktop.
Fix infinite loop while word-wrapping string in draw_text()
diff --git a/src/emu/ui/ui.c b/src/emu/ui/ui.c
index c3041a7..0eee040 100644
--- a/src/emu/ui/ui.c
+++ b/src/emu/ui/ui.c
@@ -694,6 +694,9 @@ void ui_manager::draw_text_full(render_container *container, const char *origs,
break;
curwidth -= get_font()->char_width(lineheight, aspect, schar);
+ // if back to 0, there is no space to draw even a single char
+ if (curwidth <= 0)
+ break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment