From b86703c35dd0383b0b4a9d903aea27780b7dea14 Mon Sep 17 00:00:00 2001
From: dev747368 <48332326+dev747368@users.noreply.github.com>
Date: Fri, 8 Apr 2022 18:21:27 +0000
Subject: [PATCH] GP-1902 Fix NPE in DwarfEncodingModeDataType when bad data
---
.../app/plugin/exceptionhandlers/gcc/DwarfDecoderFactory.java | 3 ++-
.../plugin/exceptionhandlers/gcc/DwarfEHDataDecodeFormat.java | 3 +--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfDecoderFactory.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfDecoderFactory.java
index b16abf9c63..7f225d0776 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfDecoderFactory.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfDecoderFactory.java
@@ -15,6 +15,7 @@
*/
package ghidra.app.plugin.exceptionhandlers.gcc;
+import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import ghidra.app.plugin.exceptionhandlers.gcc.datatype.SignedLeb128DataType;
@@ -71,7 +72,7 @@ public class DwarfDecoderFactory {
private static DwarfEHDecoder createDecoder(DwarfEHDataDecodeFormat style,
DwarfEHDataApplicationMode mod, boolean isIndirect) {
- switch (style) {
+ switch (Objects.requireNonNullElse(style, DwarfEHDataDecodeFormat.DW_EH_PE_omit)) {
case DW_EH_PE_absptr:
return new DW_EH_PE_absptr_Decoder(mod, isIndirect);
case DW_EH_PE_uleb128:
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfEHDataDecodeFormat.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfEHDataDecodeFormat.java
index 0ac545b26e..228ba80e09 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfEHDataDecodeFormat.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/exceptionhandlers/gcc/DwarfEHDataDecodeFormat.java
@@ -1,6 +1,5 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +17,7 @@ package ghidra.app.plugin.exceptionhandlers.gcc;
/**
* Exception handling data decoding formats.
- * See the Linux Standard Base DWARF extensions specification for details.
+ * See the Linux Standard Base DWARF extensions specification for details.
*/
public enum DwarfEHDataDecodeFormat {
// @formatter:off