Fix line counting in StringView.cpp
- if fText is an empty string, we would start searching past its end, possibly leading to a crash (noticed this in HaikuDepot). - if fText is NULL, BString would report a size of 0 lines, it makes more sense to report a size of 1 line.
This commit is contained in:
parent
53ce162d3d
commit
a4ba432352
@ -591,8 +591,8 @@ BStringView::_ValidatePreferredSize()
|
||||
font_height fontHeight;
|
||||
GetFontHeight(&fontHeight);
|
||||
|
||||
int32 lines = 0;
|
||||
char* temp = fText;
|
||||
int32 lines = 1;
|
||||
char* temp = fText ? strchr(fText, '\n') : NULL;
|
||||
while (temp != NULL) {
|
||||
temp = strchr(temp + 1, '\n');
|
||||
lines++;
|
||||
|
Loading…
Reference in New Issue
Block a user