diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-06-18 11:27:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2015-06-18 11:27:44 -0300 |
| commit | 95c314439342d3919b4ac8b6b84902d683cfee8d (patch) | |
| tree | b5d7ffa6781fee8bea43c4885651106ab4c05b5a | |
| parent | 19eb6ae5801a6e3c57031065c104f91de7f2c5e8 (diff) | |
| download | lua-95c314439342d3919b4ac8b6b84902d683cfee8d.tar.gz lua-95c314439342d3919b4ac8b6b84902d683cfee8d.tar.bz2 lua-95c314439342d3919b4ac8b6b84902d683cfee8d.zip | |
redefine 'l_sprintf' to test correctness of buffer sizes given
to 'snprintf'
| -rw-r--r-- | ltests.h | 11 |
1 files changed, 10 insertions, 1 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltests.h,v 2.46 2014/12/19 13:33:06 roberto Exp roberto $ | 2 | ** $Id: ltests.h,v 2.47 2014/12/26 14:44:44 roberto Exp roberto $ |
| 3 | ** Internal Header for Debugging of the Lua Implementation | 3 | ** Internal Header for Debugging of the Lua Implementation |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -37,6 +37,15 @@ | |||
| 37 | #define UNUSED(x) (x=0, (void)(x)) | 37 | #define UNUSED(x) (x=0, (void)(x)) |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | /* test for sizes in 'l_sprintf' (make sure whole buffer is available) */ | ||
| 41 | #undef l_sprintf | ||
| 42 | #if !defined(LUA_USE_C89) | ||
| 43 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), snprintf(s,sz,f,i)) | ||
| 44 | #else | ||
| 45 | #define l_sprintf(s,sz,f,i) (memset(s,0xAB,sz), sprintf(s,f,i)) | ||
| 46 | #endif | ||
| 47 | |||
| 48 | |||
| 40 | /* memory-allocator control variables */ | 49 | /* memory-allocator control variables */ |
| 41 | typedef struct Memcontrol { | 50 | typedef struct Memcontrol { |
| 42 | unsigned long numblocks; | 51 | unsigned long numblocks; |
