This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 6722436c25bf3899cc2c3c2b44ed0382e04a7fff (commit) from d5cdf89dd42290ce846e29309879a9263aa9e023 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/6722436c25bf3899cc2c3c2b44ed0382e04a7...
commit 6722436c25bf3899cc2c3c2b44ed0382e04a7fff Author: BlueBear jiri.bluebear.dluhos@gmail.com Date: Sun May 8 20:54:39 2011 +0200
Better sanity checks for text routines.
diff --git a/core/GP_Font.h b/core/GP_Font.h index 91ecd3b..0354948 100644 --- a/core/GP_Font.h +++ b/core/GP_Font.h @@ -102,6 +102,13 @@ typedef struct GP_Font { uint8_t *data; } GP_Font;
+#define GP_CHECK_FONT(font) do { + GP_CHECK(font->data, "invalid font: NULL font data"); + GP_CHECK(font->height > 0, "invalid font: height == 0"); + GP_CHECK(font->baseline <= font->height, "invalid font: baseline exceeds height"); + GP_CHECK(font->bytes_per_line > 0, "invalid font: bytes_per_line == 0"); +} while(0) + /* Data describing a single character. */ typedef struct GP_CharData {
diff --git a/core/GP_Text.c b/core/GP_Text.c index e3bcbb2..f9bc779 100644 --- a/core/GP_Text.c +++ b/core/GP_Text.c @@ -43,9 +43,8 @@ GP_RetCode GP_Text(GP_Context *context, const GP_TextStyle *style, int x, int y, int align, const char *str, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); + GP_CHECK_TEXT_STYLE(style);
- if (style != NULL && style->font == NULL) - return GP_ENULLPTR; if (str == NULL) return GP_ENULLPTR;
@@ -96,9 +95,8 @@ GP_RetCode GP_TText(GP_Context *context, const GP_TextStyle *style, int x, int y, int align, const char *str, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); + GP_CHECK_TEXT_STYLE(style); - if (style != NULL && style->font == NULL) - return GP_ENULLPTR; if (str == NULL) return GP_ENULLPTR;
@@ -147,9 +145,8 @@ GP_RetCode GP_BoxCenteredText(GP_Context *context, const GP_TextStyle *style, int x, int y, int w, int h, const char *str, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); + GP_CHECK_TEXT_STYLE(style);
- if (style != NULL && style->font == NULL) - return GP_ENULLPTR; if (str == NULL) return GP_ENULLPTR;
@@ -170,9 +167,8 @@ GP_RetCode GP_TBoxCenteredText(GP_Context *context, const GP_TextStyle *style, int x, int y, int w, int h, const char *str, GP_Pixel pixel) { GP_CHECK_CONTEXT(context); + GP_CHECK_TEXT_STYLE(style);
- if (style != NULL && style->font == NULL) - return GP_ENULLPTR; if (str == NULL) return GP_ENULLPTR;
diff --git a/core/GP_TextStyle.h b/core/GP_TextStyle.h index 8e33eb9..d79a326 100644 --- a/core/GP_TextStyle.h +++ b/core/GP_TextStyle.h @@ -64,7 +64,8 @@ void GP_DefaultTextStyle(GP_TextStyle *style);
#define GP_CHECK_TEXT_STYLE(style) do { GP_CHECK(style, "NULL style specified"); - GP_CHECK(style->font, "NULL font specified in style"); + GP_CHECK(style->font, "invalid text style: font is NULL"); + GP_CHECK_FONT(style->font); } while(0)
#endif /* GP_TEXTSTYLE_H */
-----------------------------------------------------------------------
Summary of changes: core/GP_Font.h | 7 +++++++ core/GP_Text.c | 12 ++++-------- core/GP_TextStyle.h | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.