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/PixelMethods.inc | |
| 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/PixelMethods.inc')
| -rw-r--r-- | src/PixelMethods.inc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/PixelMethods.inc b/src/PixelMethods.inc index eff0b60..4d85f60 100644 --- a/src/PixelMethods.inc +++ b/src/PixelMethods.inc @@ -6,6 +6,7 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int return 0; int width, height; + int oR = r, oG = g, oB = b; int characterX = x, characterY = y; int startX = characterX; for (; *s; s++) @@ -15,8 +16,23 @@ int PIXELMETHODS_CLASS::drawtext(int x, int y, const char *s, int r, int g, int 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': |
