Răsfoiți Sursa

Fixed a possibility of buffer overflow in Superscalar generator

tevador 7 ani în urmă
părinte
comite
3f7139d3aa
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      src/superscalar.cpp

+ 1 - 1
src/superscalar.cpp

@@ -679,7 +679,7 @@ namespace randomx {
 
 
 				//if we have issued all macro-ops for the current RandomX instruction, create a new instruction
 				//if we have issued all macro-ops for the current RandomX instruction, create a new instruction
 				if (macroOpIndex >= currentInstruction.getInfo().getSize()) {
 				if (macroOpIndex >= currentInstruction.getInfo().getSize()) {
-					if (portsSaturated)
+					if (portsSaturated || programSize >= RANDOMX_SUPERSCALAR_MAX_SIZE)
 						break;
 						break;
 					//select an instruction so that the first macro-op fits into the current slot
 					//select an instruction so that the first macro-op fits into the current slot
 					currentInstruction.createForSlot(gen, decodeBuffer->getCounts()[bufferIndex], decodeBuffer->getIndex(), decodeBuffer->getSize() == bufferIndex + 1, bufferIndex == 0);
 					currentInstruction.createForSlot(gen, decodeBuffer->getCounts()[bufferIndex], decodeBuffer->getIndex(), decodeBuffer->getSize() == bufferIndex + 1, bufferIndex == 0);