aboutsummaryrefslogtreecommitdiff
path: root/src/lj_strfmt.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lj_strfmt.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lj_strfmt.c b/src/lj_strfmt.c
index 7b073470..945954aa 100644
--- a/src/lj_strfmt.c
+++ b/src/lj_strfmt.c
@@ -431,7 +431,7 @@ int lj_strfmt_putarg(lua_State *L, SBuf *sb, int arg, int retry)
431 MSize len; 431 MSize len;
432 const char *s; 432 const char *s;
433 cTValue *mo; 433 cTValue *mo;
434 if (LJ_UNLIKELY(!tvisstr(o)) && retry >= 0 && 434 if (LJ_UNLIKELY(!tvisstr(o) && !tvisbuf(o)) && retry >= 0 &&
435 !tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) { 435 !tvisnil(mo = lj_meta_lookup(L, o, MM_tostring))) {
436 /* Call __tostring metamethod once. */ 436 /* Call __tostring metamethod once. */
437 copyTV(L, L->top++, mo); 437 copyTV(L, L->top++, mo);
@@ -447,10 +447,13 @@ int lj_strfmt_putarg(lua_State *L, SBuf *sb, int arg, int retry)
447 if (LJ_LIKELY(tvisstr(o))) { 447 if (LJ_LIKELY(tvisstr(o))) {
448 len = strV(o)->len; 448 len = strV(o)->len;
449 s = strVdata(o); 449 s = strVdata(o);
450#if LJ_HASBUFFER
450 } else if (tvisbuf(o)) { 451 } else if (tvisbuf(o)) {
451 SBufExt *sbx = bufV(o); 452 SBufExt *sbx = bufV(o);
453 if (sbx == (SBufExt *)sb) lj_err_arg(L, arg+1, LJ_ERR_BUFFER_SELF);
452 len = sbufxlen(sbx); 454 len = sbufxlen(sbx);
453 s = sbx->r; 455 s = sbx->r;
456#endif
454 } else { 457 } else {
455 GCstr *str = lj_strfmt_obj(L, o); 458 GCstr *str = lj_strfmt_obj(L, o);
456 len = str->len; 459 len = str->len;