summaryrefslogtreecommitdiff
path: root/src/lj_str.c
diff options
context:
space:
mode:
authorMike Pall <mike>2011-06-07 21:10:04 +0200
committerMike Pall <mike>2011-06-07 21:10:04 +0200
commita0840d269546bc0b314dd2d0bcebe1785beb9f62 (patch)
treefc61adf68351631c8759e04e774b76b71f7ba333 /src/lj_str.c
parenta7ca722dca4b96367dff34402b21901f3e44a3cf (diff)
downloadluajit2-a0840d269546bc0b314dd2d0bcebe1785beb9f62.tar.gz
FFI: Print NULL pointers as "cdata<... *>: NULL".
Diffstat (limited to 'src/lj_str.c')
-rw-r--r--src/lj_str.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lj_str.c b/src/lj_str.c
index a5d894e0..cd3a8b69 100644
--- a/src/lj_str.c
+++ b/src/lj_str.c
@@ -360,6 +360,10 @@ const char *lj_str_pushvf(lua_State *L, const char *fmt, va_list argp)
char buf[2+FMTP_CHARS];
ptrdiff_t p = (ptrdiff_t)(va_arg(argp, void *));
ptrdiff_t i, lasti = 2+FMTP_CHARS;
+ if (p == 0) {
+ addstr(L, sb, "NULL", 4);
+ break;
+ }
#if LJ_64
/* Shorten output for 64 bit pointers. */
lasti = 2+2*4+((p >> 32) ? 2+2*(lj_fls((uint32_t)(p >> 32))>>3) : 0);