Skip to content

Commit eedbd62

Browse files
authored
Merge pull request #81 from blep/devel
Fix NFD_PickFolder() asserting in debug with non ASCII default path
2 parents dbb8a4b + ad0b798 commit eedbd62

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/nfd_common.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ int32_t NFDi_UTF8_Strlen( const nfdchar_t *str )
113113
int32_t character_count = 0;
114114
int32_t i = 0; /* Counter used to iterate over string. */
115115
nfdchar_t maybe_bom[4];
116+
unsigned char c;
116117

117118
/* If there is UTF-8 BOM ignore it. */
118119
if (strlen(str) > 2)
@@ -125,17 +126,18 @@ int32_t NFDi_UTF8_Strlen( const nfdchar_t *str )
125126

126127
while(str[i])
127128
{
128-
if (str[i] >> 7 == 0)
129+
c = (unsigned char)str[i];
130+
if (c >> 7 == 0)
129131
{
130132
/* If bit pattern begins with 0 we have ascii character. */
131133
++character_count;
132134
}
133-
else if (str[i] >> 6 == 3)
135+
else if (c >> 6 == 3)
134136
{
135137
/* If bit pattern begins with 11 it is beginning of UTF-8 byte sequence. */
136138
++character_count;
137139
}
138-
else if (str[i] >> 6 == 2)
140+
else if (c >> 6 == 2)
139141
; /* If bit pattern begins with 10 it is middle of utf-8 byte sequence. */
140142
else
141143
{

0 commit comments

Comments
 (0)