diff options
Diffstat (limited to 'lauxlib.c')
-rw-r--r-- | lauxlib.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.281 2015/06/18 14:23:14 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.282 2015/10/02 15:46:49 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -512,9 +512,11 @@ LUALIB_API char *luaL_prepbuffsize (luaL_Buffer *B, size_t sz) { | |||
512 | 512 | ||
513 | 513 | ||
514 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { | 514 | LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) { |
515 | char *b = luaL_prepbuffsize(B, l); | 515 | if (l > 0) { /* avoid 'memcpy' when 's' can be NULL */ |
516 | memcpy(b, s, l * sizeof(char)); | 516 | char *b = luaL_prepbuffsize(B, l); |
517 | luaL_addsize(B, l); | 517 | memcpy(b, s, l * sizeof(char)); |
518 | luaL_addsize(B, l); | ||
519 | } | ||
518 | } | 520 | } |
519 | 521 | ||
520 | 522 | ||