Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-19 18:09:13 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-09-19 18:09:13 +0400
commit5c7b5c0b51f57ad19b79eac78e3e4afb263b23cc (patch)
tree28032da573c9366ab0d0f16ae1c93273108d13e4
parent712e434a5f71fc4afc52e399af917d137c49308b (diff)
Blenfont: fix use incorrect clear of ascii glyph cache, leading to crash
when toggling use antialising user preference. Also fix some other use of uninitialized memory found by valgrind.
-rw-r--r--source/blender/blenfont/intern/blf_dir.c4
-rw-r--r--source/blender/blenfont/intern/blf_font.c4
-rw-r--r--source/blender/blenfont/intern/blf_glyph.c17
3 files changed, 7 insertions, 18 deletions
diff --git a/source/blender/blenfont/intern/blf_dir.c b/source/blender/blenfont/intern/blf_dir.c
index 1c99af0c7a9..46be49b37e9 100644
--- a/source/blender/blenfont/intern/blf_dir.c
+++ b/source/blender/blenfont/intern/blf_dir.c
@@ -76,7 +76,7 @@ void BLF_dir_add(const char *path)
if (dir) /* already in the list ? just return. */
return;
- dir= (DirBLF *)MEM_mallocN(sizeof(DirBLF), "BLF_dir_add");
+ dir= (DirBLF *)MEM_callocN(sizeof(DirBLF), "BLF_dir_add");
dir->path= BLI_strdup(path);
BLI_addhead(&global_font_dir, dir);
}
@@ -104,7 +104,7 @@ char **BLF_dir_get(int *ndir)
if (!count)
return NULL;
- dirs= (char **)MEM_mallocN(sizeof(char *) * count, "BLF_dir_get");
+ dirs= (char **)MEM_callocN(sizeof(char *) * count, "BLF_dir_get");
p= global_font_dir.first;
i= 0;
while (p) {
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index f3f3b759e5c..26af3a3fd4f 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -511,7 +511,7 @@ FontBLF *blf_font_new(const char *name, const char *filename)
FT_Error err;
char *mfile;
- font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new");
+ font= (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new");
err= FT_New_Face(ft_lib, filename, 0, &font->face);
if (err) {
MEM_freeN(font);
@@ -553,7 +553,7 @@ FontBLF *blf_font_new_from_mem(const char *name, unsigned char *mem, int mem_siz
FontBLF *font;
FT_Error err;
- font= (FontBLF *)MEM_mallocN(sizeof(FontBLF), "blf_font_new_from_mem");
+ font= (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new_from_mem");
err= FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face);
if (err) {
MEM_freeN(font);
diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c
index b661005b50b..99d41cd7abd 100644
--- a/source/blender/blenfont/intern/blf_glyph.c
+++ b/source/blender/blenfont/intern/blf_glyph.c
@@ -75,7 +75,7 @@ GlyphCacheBLF *blf_glyph_cache_new(FontBLF *font)
{
GlyphCacheBLF *gc;
- gc= (GlyphCacheBLF *)MEM_mallocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new");
+ gc= (GlyphCacheBLF *)MEM_callocN(sizeof(GlyphCacheBLF), "blf_glyph_cache_new");
gc->next= NULL;
gc->prev= NULL;
gc->size= font->size;
@@ -131,10 +131,8 @@ void blf_glyph_cache_clear(FontBLF *font)
blf_glyph_free(g);
}
}
- }
- if(font->glyph_cache) {
- memset(font->glyph_cache->glyph_ascii_table, 0, sizeof(font->glyph_cache->glyph_ascii_table));
+ memset(gc->glyph_ascii_table, 0, sizeof(gc->glyph_ascii_table));
}
}
@@ -250,20 +248,11 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c)
if (err || slot->format != FT_GLYPH_FORMAT_BITMAP)
return NULL;
- g= (GlyphBLF *)MEM_mallocN(sizeof(GlyphBLF), "blf_glyph_add");
- g->next= NULL;
- g->prev= NULL;
+ g= (GlyphBLF *)MEM_callocN(sizeof(GlyphBLF), "blf_glyph_add");
g->c= c;
g->idx= (FT_UInt)index;
- g->tex= 0;
- g->build_tex= 0;
- g->bitmap= NULL;
g->xoff= -1;
g->yoff= -1;
- g->uv[0][0]= 0.0f;
- g->uv[0][1]= 0.0f;
- g->uv[1][0]= 0.0f;
- g->uv[1][1]= 0.0f;
bitmap= slot->bitmap;
g->width= bitmap.width;
g->height= bitmap.rows;