Skip to content

Commit a9c3b6b

Browse files
committed
Fix: Fix memory leak in Text::TextureString::resize
1 parent 872cfcd commit a9c3b6b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/flamegpu/visualiser/ui/Text.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,14 @@ Text::TextureString::TextureString()
376376
}
377377
void Text::TextureString::resize(const glm::uvec2 &_dimensions) {
378378
this->dimensions = _dimensions;
379-
if (texture)
379+
if (texture) {
380+
if (texture[0]) {
381+
free(texture[0]);
382+
texture[0] = nullptr;
383+
}
380384
free(texture);
385+
texture = nullptr;
386+
}
381387
texture = reinterpret_cast<unsigned char**>(malloc(sizeof(char*) * this->dimensions.y));
382388
texture[0] = reinterpret_cast<unsigned char*>(malloc(sizeof(char) * this->dimensions.x * this->dimensions.y));
383389
memset(texture[0], 0, sizeof(char)*this->dimensions.x*this->dimensions.y);

0 commit comments

Comments
 (0)