Bug: Loading a corrupted binary file can segfault
The size of the list of upvalue names are stored separated from the size of the list of upvalues, but they share the same array.
This commit is contained in:
8
ldump.c
8
ldump.c
@@ -10,6 +10,7 @@
|
||||
#include "lprefix.h"
|
||||
|
||||
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "lua.h"
|
||||
@@ -55,8 +56,11 @@ static void dumpByte (DumpState *D, int y) {
|
||||
}
|
||||
|
||||
|
||||
/* dumpInt Buff Size */
|
||||
#define DIBS ((sizeof(size_t) * 8 / 7) + 1)
|
||||
/*
|
||||
** 'dumpSize' buffer size: each byte can store up to 7 bits. (The "+6"
|
||||
** rounds up the division.)
|
||||
*/
|
||||
#define DIBS ((sizeof(size_t) * CHAR_BIT + 6) / 7)
|
||||
|
||||
static void dumpSize (DumpState *D, size_t x) {
|
||||
lu_byte buff[DIBS];
|
||||
|
||||
Reference in New Issue
Block a user