Skip to content

Commit 6e89064

Browse files
author
Swagtoy
committed
Add a comment to elaborate on irrString use-after-free
1 parent 216cbfc commit 6e89064

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

irr/include/irrString.h

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ class string
177177
_IRR_DEBUG_BREAK_IF((void *)c == (void *)c_str());
178178

179179
u32 len = calclen(c);
180+
// We must check if the new length is different, otherwise we experience
181+
// a use-after-free. In such a case, we decide whether to resize based
182+
// on it's length.
180183
if (len > str.size()) str.resize(len);
181184
for (u32 l = 0; l < len; ++l)
182185
str[l] = static_cast<T>(c[l]);

0 commit comments

Comments
 (0)