Unified · Split
| @@ -102,8 +102,10 @@ pt_font(uchar *data, float height) · 101 unmodified lines | ||
| 102 | 102 | Sfont *f; |
| 103 | 103 | |
| 104 | 104 | f = mallocz(sizeof(*f), 1); |
| 105 | − if(stbtt_InitFont(&f->fi, data, stbtt_GetFontOffsetForIndex(data, 0)) == 0) | |
| 105 | + if(stbtt_InitFont(&f->fi, data, stbtt_GetFontOffsetForIndex(data, 0)) == 0){ | |
| 106 | + werrstr("stbtt_InitFont: %r"); | |
| 106 | 107 | goto err; |
| 108 | + } | |
| 107 | 109 | |
| 108 | 110 | f->scale = stbtt_ScaleForPixelHeight(&f->fi, height); |
| 109 | 111 | f->height = height; |
| @@ -119,6 +121,10 @@ pt_font(uchar *data, float height) · 9 unmodified lines | ||
| 119 | 121 | f->bb.max.x = (f->bb.max.x + 3) & ~3; |
| 120 | 122 | f->bb.max.y = (f->bb.max.y + 3) & ~3; |
| 121 | 123 | |
| 124 | + if(badrect(f->bb)){ | |
| 125 | + werrstr("invalid glyph bbox: %R", f->bb); | |
| 126 | + goto err; | |
| 127 | + } | |
| 122 | 128 | if((f->g = allocmemimage(f->bb, GREY8)) == nil) |
| 123 | 129 | goto err; |
| 124 | 130 | if((f->b = allocmemimage(f->bb, GREY8)) == nil) |
| @@ -127,6 +133,7 @@ pt_font(uchar *data, float height) · 2 unmodified lines | ||
| 127 | 133 | |
| 128 | 134 | return f; |
| 129 | 135 | err: |
| 136 | + werrstr("pt_font: %r"); | |
| 130 | 137 | pt_freefont(f); |
| 131 | 138 | return nil; |
| 132 | 139 | } |
| @@ -193,7 +193,8 @@ threadmain(int argc, char **argv) · 192 unmodified lines | ||
| 193 | 193 | |
| 194 | 194 | changed: |
| 195 | 195 | pt_freefont(fo); |
| 196 | − fo = pt_font(data, height); | |
| 196 | + if((fo = pt_font(data, height)) == nil) | |
| 197 | + sysfatal("%r"); | |
| 197 | 198 | rect = pt_textrect(fo, s); |
| 198 | 199 | freeimage(image); |
| 199 | 200 | image = pt_textdraw(fo, s, rect, &opts); |