Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,14 @@ Render2DSentenceClass::Allocate_New_Surface (const WCHAR *text, bool justCalcExt

int char_height = Font->Get_Char_Height ();

//
// Validate char_height to prevent division by zero
// In rare cases with corrupted fonts, this can be 0 or negative
//
if (char_height <= 0) {
char_height = 1; // Use minimum safe value
}

//
// Find the best texture size for the remaining text
//
Expand Down Expand Up @@ -1631,6 +1639,14 @@ FontCharsClass::Create_GDI_Font (const char *font_name)
CharOverhang = 0;
}

//
// Validate CharHeight to prevent division by zero
// In rare cases with corrupted fonts, tmHeight can be 0 or negative
//
if (CharHeight <= 0) {
CharHeight = 1; // Use minimum safe value
}

return GDIFont != NULL && GDIBitmap != NULL;
}

Expand Down
Loading