1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[RISCV] Fix a potential issue in shouldInsertFixupForCodeAlign()

The bool result of shouldInsertExtraNopBytesForCodeAlign() is not checked but
the returned nop count is unconditionally read even though it could be
uninitialized.

Differential Revision: https://reviews.llvm.org/D63285
Patch by Edward Jones.

llvm-svn: 366175
This commit is contained in:
Alex Bradbury 2019-07-16 04:37:19 +00:00
parent 8e05833474
commit 066798ae68

View File

@ -329,11 +329,10 @@ bool RISCVAsmBackend::shouldInsertFixupForCodeAlign(MCAssembler &Asm,
if (!STI.getFeatureBits()[RISCV::FeatureRelax])
return false;
// Calculate total Nops we need to insert.
// Calculate total Nops we need to insert. If there are none to insert
// then simply return.
unsigned Count;
shouldInsertExtraNopBytesForCodeAlign(AF, Count);
// No Nop need to insert, simply return.
if (Count == 0)
if (!shouldInsertExtraNopBytesForCodeAlign(AF, Count) || (Count == 0))
return false;
MCContext &Ctx = Asm.getContext();