diff --git a/libunwind/src/DwarfParser.hpp b/libunwind/src/DwarfParser.hpp
index 26993c4e0d1b..a19f0510a37b 100644
--- a/libunwind/src/DwarfParser.hpp
+++ b/libunwind/src/DwarfParser.hpp
@@ -380,7 +380,9 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions,
uint64_t length;
uint8_t opcode = addressSpace.get8(p);
uint8_t operand;
+#if !defined(_LIBUNWIND_NO_HEAP)
PrologInfoStackEntry *entry;
+#endif
++p;
switch (opcode) {
case DW_CFA_nop:
@@ -492,6 +494,7 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions,
fprintf(stderr, "DW_CFA_register(reg=%" PRIu64 ", reg2=%" PRIu64 ")\n",
reg, reg2);
break;
+#if !defined(_LIBUNWIND_NO_HEAP)
case DW_CFA_remember_state:
// avoid operator new, because that would be an upward dependency
entry = (PrologInfoStackEntry *)malloc(sizeof(PrologInfoStackEntry));
@@ -517,6 +520,7 @@ bool CFI_Parser::parseInstructions(A &addressSpace, pint_t instructions,
if (logDwarf)
fprintf(stderr, "DW_CFA_restore_state\n");
break;
+#endif
case DW_CFA_def_cfa:
reg = addressSpace.getULEB128(p, instructionsEnd);
offset = (int64_t)addressSpace.getULEB128(p, instructionsEnd);
diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index 040d13e92563..90683164ff24 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -114,6 +114,7 @@ typename A::pint_t DwarfFDECache::findFDE(pint_t mh, pint_t pc) {
template
void DwarfFDECache::add(pint_t mh, pint_t ip_start, pint_t ip_end,
pint_t fde) {
+#if !defined(_LIBUNWIND_NO_HEAP)
_LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_wrlock(&_lock));
if (_bufferUsed >= _bufferEnd) {
size_t oldSize = (size_t)(_bufferEnd - _buffer);
@@ -139,6 +140,7 @@ void DwarfFDECache::add(pint_t mh, pint_t ip_start, pint_t ip_end,
}
#endif
_LIBUNWIND_LOG_NON_ZERO(::pthread_rwlock_unlock(&_lock));
+#endif
}
template