diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-26 13:31:10 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-06-26 13:31:10 (GMT) |
| commit | e26cb8ce2f69b81442194bd2310cfc3ea6bb6f5f (patch) | |
| tree | 87f76f3c1c7a8a3fe071e761207f334aede4ca0b /src/OpenGLGraphics.cpp | |
| parent | 694a6ed4f2066bf4617395247e4604e711d92c26 (diff) | |
| download | powder-e26cb8ce2f69b81442194bd2310cfc3ea6bb6f5f.zip powder-e26cb8ce2f69b81442194bd2310cfc3ea6bb6f5f.tar.gz | |
Fix potential crash where strings fed into any of the text functions have a trailing '\b'/'\x08'
Diffstat (limited to 'src/OpenGLGraphics.cpp')
| -rw-r--r-- | src/OpenGLGraphics.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/OpenGLGraphics.cpp b/src/OpenGLGraphics.cpp index ce65ad2..b6f8f2a 100644 --- a/src/OpenGLGraphics.cpp +++ b/src/OpenGLGraphics.cpp @@ -70,6 +70,7 @@ int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) { if(!strlen(s)) return 0; + int oR = r, oG = g, oB = b; int width, height; Graphics::textsize(s, width, height); VideoBuffer texture(width, height); @@ -82,8 +83,23 @@ int Graphics::drawtext(int x, int y, const char *s, int r, int g, int b, int a) characterX = startX; characterY += FONT_H+2; } + else if (*s == '\x0F') + { + if(!s[1] || !s[2] || !s[3]) break; + r = s[1]; + g = s[2]; + b = s[3]; + s += 3; + } + else if (*s == '\x0E') + { + r = oR; + g = oG; + b = oB; + } else if (*s == '\b') { + if(!s[1]) break; switch (s[1]) { case 'w': |
