diff options
author | Kim Alvefur <zash@zash.se> | 2020-05-29 18:11:42 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2020-05-29 18:11:42 +0200 |
commit | 0bb1474ce668f50c568e7751ac553cbf0acdba77 (patch) | |
tree | 201cf90725615fd50a3a03d260a6aff23a5987a0 /util-src/ringbuffer.c | |
parent | 838f8ebd5bb26c2c96644af9e4f80ea7e150d976 (diff) | |
download | prosody-0bb1474ce668f50c568e7751ac553cbf0acdba77.tar.gz prosody-0bb1474ce668f50c568e7751ac553cbf0acdba77.zip |
util.ringbuffer: Prevent creation of zero-size buffer
Diffstat (limited to 'util-src/ringbuffer.c')
-rw-r--r-- | util-src/ringbuffer.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/util-src/ringbuffer.c b/util-src/ringbuffer.c index 3e17cdf5..f4a51cc9 100644 --- a/util-src/ringbuffer.c +++ b/util-src/ringbuffer.c @@ -198,6 +198,7 @@ static int rb_free(lua_State *L) { static int rb_new(lua_State *L) { size_t size = luaL_optinteger(L, 1, sysconf(_SC_PAGESIZE)); + luaL_argcheck(L, size > 0, 1, "positive integer expected"); ringbuffer *b = lua_newuserdata(L, sizeof(ringbuffer) + size); b->rpos = 0; |