From f6fcccfcad081f70a4a9ac7b45146d0ad9e4ffae Mon Sep 17 00:00:00 2001 From: Marc-Andre Laperle Date: Tue, 5 Nov 2013 00:34:50 -0500 Subject: [PATCH] Bug 421041 - NPE in EvalBinding.getBinding This happens when constructor EvalBinding(IBinding binding, IType type, IBinding templateDefinition) is called with a null binding. A binding can be null for example when TypeMarshalBuffer.unmarshalBinding returns null. Instead of returning null, unmarshalBinding can return a ProblemBinding and the assumptions that the binding in EvalBinding is not null can be maintained. Change-Id: Icebf875e059f2962cc2ddd91d3b79c51b88eddac Signed-off-by: Marc-Andre Laperle Reviewed-on: https://git.eclipse.org/r/18064 --- .../eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java index 8846cc615be..44339816258 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/TypeMarshalBuffer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2014 Wind River Systems, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.internal.core.dom.parser.ISerializableEvaluation; import org.eclipse.cdt.internal.core.dom.parser.ISerializableType; import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer; +import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateNonTypeArgument; @@ -106,7 +107,7 @@ public final class TypeMarshalBuffer implements ITypeMarshalBuffer { long rec= getRecordPointer(); return (IBinding) PDOMNode.load(fLinkage.getPDOM(), rec); } else if (firstBytes == NULL_TYPE || firstBytes == UNSTORABLE_TYPE) { - return null; + return new ProblemBinding(null, ISemanticProblem.TYPE_NOT_PERSISTED); } fPos = oldPos; // fLinkage.unmarshalBinding() will read firstBytes again