x86: fix a race condition made by a static variable initialization. bug reported by Xiaozhu Meng

This commit is contained in:
naq 2019-06-19 10:44:13 +08:00
parent c602427ca3
commit 30bffad2d4

View File

@ -159,11 +159,8 @@ static InstrUID decode(OpcodeType type,
uint8_t modRM)
{
const struct ModRMDecision *dec = NULL;
static unsigned int index = -1;
static struct OpcodeDecision emptyDecision;
if (index == -1)
memset((void *)&emptyDecision, 0, sizeof(emptyDecision));
unsigned int index;
static struct OpcodeDecision emptyDecision = { 0 };
switch (type) {
default: break; // never reach