Browse Source

really fixed memory issue

Ron Aaron 5 years ago
parent
commit
3d84f6c42c
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/nuklear_font.c

+ 2 - 1
src/nuklear_font.c

@@ -138,7 +138,7 @@ nk_font_baker_memory(nk_size *temp, int *glyph_count,
         } while ((i = i->n) != iter);
     }
     *temp = (nk_size)*glyph_count * sizeof(struct stbrp_rect);
-    *temp += (nk_size)*glyph_count * sizeof(stbtt_pack_range);
+    *temp += (nk_size)total_range_count * sizeof(stbtt_pack_range);
     *temp += (nk_size)*glyph_count * sizeof(stbtt_packedchar);
     *temp += (nk_size)count * sizeof(struct nk_font_bake_data);
     *temp += sizeof(struct nk_font_baker);
@@ -1179,6 +1179,7 @@ nk_font_atlas_bake(struct nk_font_atlas *atlas, int *width, int *height,
     tmp = atlas->temporary.alloc(atlas->temporary.userdata,0, tmp_size);
     NK_ASSERT(tmp);
     if (!tmp) goto failed;
+	memset(tmp,0,tmp_size);
 
     /* allocate glyph memory for all fonts */
     baker = nk_font_baker(tmp, atlas->glyph_count, atlas->font_num, &atlas->temporary);