소스 검색

Fix read after deallocation

Daniele Bartolini 11 년 전
부모
커밋
22a7d728cd
1개의 변경된 파일3개의 추가작업 그리고 3개의 파일을 삭제
  1. 3 3
      engine/resource/FontResource.cpp

+ 3 - 3
engine/resource/FontResource.cpp

@@ -93,9 +93,6 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 		array::push_back(m_glyphs, data);
 	}
 
-	fs.close(file);
-	default_allocator().deallocate(buf);
-
 	h.material.id = string::murmur2_64(material_name.c_str(), string::strlen(material_name.c_str()), 0);
 	h.num_glyphs = array::size(m_glyphs);
 	h.texture_size = size.to_int();
@@ -107,6 +104,9 @@ void compile(Filesystem& fs, const char* resource_path, File* out_file)
 	{
 		out_file->write((char*) array::begin(m_glyphs), sizeof(FontGlyphData) * h.num_glyphs);
 	}
+
+	fs.close(file);
+	default_allocator().deallocate(buf);
 }
 
 } // namespace font_resource