From 1d641f51972424c524b22146b307616af5c682b2 Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Mon, 29 Jul 2024 15:53:53 -0400 Subject: [PATCH] GP-4797 corrected thread safety issue with EnumDataType.getNames method --- .../app/util/bin/format/pe/PEx64UnwindInfoDataType.java | 6 +++--- .../main/java/ghidra/program/model/data/EnumDataType.java | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/PEx64UnwindInfoDataType.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/PEx64UnwindInfoDataType.java index f6b71959d8..da43861fbe 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/PEx64UnwindInfoDataType.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/pe/PEx64UnwindInfoDataType.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -164,7 +164,7 @@ public class PEx64UnwindInfoDataType extends DynamicDataType { private static EnumDataType unwindInfoFlagsEnum; - private EnumDataType defineUnwindInfoFlags() { + private synchronized EnumDataType defineUnwindInfoFlags() { if (unwindInfoFlagsEnum == null) { unwindInfoFlagsEnum = new EnumDataType("UNW_FLAGS", 1); unwindInfoFlagsEnum.add("UNW_FLAG_NHANDLER", PEx64UnwindInfo.UNW_FLAG_NHANDLER); diff --git a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/EnumDataType.java b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/EnumDataType.java index 60934ecf4d..102e19d3f1 100644 --- a/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/EnumDataType.java +++ b/Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/EnumDataType.java @@ -4,9 +4,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -130,6 +130,7 @@ public class EnumDataType extends GenericDataType implements Enum { List names = new ArrayList<>(); Collection> values = valueMap.values(); for (List list : values) { + list = new ArrayList<>(list); Collections.sort(list); names.addAll(list); }