From 1cbe7e32b9098c2ecacb80db0c6e1b7a43ab2a9b Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Tue, 16 Oct 2018 00:26:17 -0400 Subject: [PATCH] Bug 540159 - ClassCastException in ExecDeclarator.unmarshal() Change-Id: Ia51244b558798c052f1ec7a6918c6f85a6509655 --- .../dom/parser/cpp/semantics/ExecDeclarator.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java index dcddf9ac317..84fcc239d0d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/ExecDeclarator.java @@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory; import org.eclipse.cdt.core.dom.ast.IArrayType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IQualifierType; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IValue; @@ -248,8 +249,15 @@ public final class ExecDeclarator implements ICPPExecution { } public static ICPPExecution unmarshal(short firstBytes, ITypeMarshalBuffer buffer) throws CoreException { - ICPPBinding declaredBinding = (ICPPBinding) buffer.unmarshalBinding(); + IBinding declaredBinding = buffer.unmarshalBinding(); + if (declaredBinding instanceof IProblemBinding) { + // The declared binding could not be stored in the index. + // If this happens, it's almost certainly a bug, but the severity + // is mitigated by returning a problem evaluation instead of just + // trying to cast to ICPPBinding and throwing a ClassCastException. + return ExecIncomplete.INSTANCE; + } ICPPEvaluation initializerEval = buffer.unmarshalEvaluation(); - return new ExecDeclarator(declaredBinding, initializerEval); + return new ExecDeclarator((ICPPBinding) declaredBinding, initializerEval); } }