diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-04-10 12:34:45 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-04-10 18:42:45 +0300 |
commit | 21a57ec29e71b71df3e1da232c61fe2d6d0fca13 (patch) | |
tree | 680073d7dfe9771fc5626e99d310a8047d589f2a /source/blender/blenfont | |
parent | 8d1c21998ad102dd921a843055576dcef6511a37 (diff) |
BLF: Style: Fix bad casts.
This could have caused overflow issue.
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index da9aeaed449..96854db66dd 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -243,8 +243,7 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - unsigned int pix_count = (unsigned int)(gc->p2_width * gc->p2_height); - unsigned char *pixels = MEM_callocN(pix_count * sizeof(*pixels), "BLF texture init"); + unsigned char *pixels = MEM_callocN((size_t)gc->p2_width * (size_t)gc->p2_height, "BLF texture init"); glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, gc->p2_width, gc->p2_height, 0, GL_RED, GL_UNSIGNED_BYTE, pixels); MEM_freeN(pixels); } @@ -345,8 +344,8 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) } } - g->bitmap = (unsigned char *)MEM_mallocN((size_t)(g->width * g->height), "glyph bitmap"); - memcpy((void *)g->bitmap, (void *)bitmap.buffer, (size_t)(g->width * g->height)); + g->bitmap = (unsigned char *)MEM_mallocN((size_t)g->width * (size_t)g->height, "glyph bitmap"); + memcpy((void *)g->bitmap, (void *)bitmap.buffer, (size_t)g->width * (size_t)g->height); } g->advance = ((float)slot->advance.x) / 64.0f; |