Diff

util-src/ringbuffer.c @ 10953:c3b3ac63f4c3

util.ringbuffer: Ensure unsigned chars are always returned from :byte()
author Matthew Wild <mwild1@gmail.com>
date Wed, 24 Jun 2020 12:34:20 +0100
parent 10921:6eb5d2bb11af
child 12575:1f6f05a98fcd
line wrap: on
line diff
--- a/util-src/ringbuffer.c	Tue Jun 23 17:59:24 2020 +0200
+++ b/util-src/ringbuffer.c	Wed Jun 24 12:34:20 2020 +0100
@@ -262,15 +262,15 @@
 	if(calc_splice_positions(b, start, end, &wrapped_start, &wrapped_end)) {
 		if(wrapped_end <= wrapped_start) {
 			for(i = wrapped_start; i < (long)b->alen; i++) {
-				lua_pushinteger(L, b->buffer[i]);
+				lua_pushinteger(L, (unsigned char)b->buffer[i]);
 			}
 			for(i = 0; i < wrapped_end; i++) {
-				lua_pushinteger(L, b->buffer[i]);
+				lua_pushinteger(L, (unsigned char)b->buffer[i]);
 			}
 			return wrapped_end + (b->alen - wrapped_start);
 		} else {
 			for(i = wrapped_start; i < wrapped_end; i++) {
-				lua_pushinteger(L, b->buffer[i]);
+				lua_pushinteger(L, (unsigned char)b->buffer[i]);
 			}
 			return wrapped_end - wrapped_start;
 		}