mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Fix string buffer COW handling, part 2.
Reported by XmiliaH.
This commit is contained in:
parent
f004a51b3a
commit
aa0550e3f0
@ -76,6 +76,8 @@ LJLIB_CF(buffer_method_skip) LJLIB_REC(.)
|
|||||||
MSize len = sbufxlen(sbx);
|
MSize len = sbufxlen(sbx);
|
||||||
if (n < len) {
|
if (n < len) {
|
||||||
sbx->r += n;
|
sbx->r += n;
|
||||||
|
} else if (sbufiscow(sbx)) {
|
||||||
|
sbx->r = sbx->w;
|
||||||
} else {
|
} else {
|
||||||
sbx->r = sbx->w = sbx->b;
|
sbx->r = sbx->w = sbx->b;
|
||||||
}
|
}
|
||||||
@ -173,7 +175,7 @@ LJLIB_CF(buffer_method_get) LJLIB_REC(.)
|
|||||||
setstrV(L, o, lj_str_new(L, sbx->r, n));
|
setstrV(L, o, lj_str_new(L, sbx->r, n));
|
||||||
sbx->r += n;
|
sbx->r += n;
|
||||||
}
|
}
|
||||||
if (sbx->r == sbx->w) sbx->r = sbx->w = sbx->b;
|
if (sbx->r == sbx->w && !sbufiscow(sbx)) sbx->r = sbx->w = sbx->b;
|
||||||
lj_gc_check(L);
|
lj_gc_check(L);
|
||||||
return narg-1;
|
return narg-1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user