Skip to content

Commit 6966688

Browse files
author
Swagtoy
committed
Improve comment
1 parent 2148ce3 commit 6966688

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

irr/include/irrString.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,8 @@ class string
174174
}
175175

176176
u32 len = calclen(c);
177-
// We must check if the new length is different, otherwise we experience
178-
// a use-after-free. In such a case, we decide whether to resize based
179-
// on it's length.
177+
// In case `c` is a pointer to our own buffer, we may not resize first
178+
// or it can become invalid.
180179
if (len > str.size()) str.resize(len);
181180
for (u32 l = 0; l < len; ++l)
182181
str[l] = static_cast<T>(c[l]);

0 commit comments

Comments
 (0)