From fcd3e477bda8fde67bd9863be44b0f89d412eed7 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Fri, 7 Mar 2008 08:48:05 +0000 Subject: [PATCH] Fix for potential NPEs, bug 221796. --- .../internal/core/dom/parser/cpp/CPPImplicitFunction.java | 7 ++++--- .../cdt/internal/core/dom/parser/cpp/CPPMethod.java | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java index cc562fcb7aa..0277db93e26 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPImplicitFunction.java @@ -1,12 +1,13 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation 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 * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -122,7 +123,7 @@ public class CPPImplicitFunction extends CPPFunction implements ICPPFunction, IC ((CPPParameter)binding).addDeclaration( n ); } if( declarations != null ){ - for( int j = 0; j < declarations.length; j++ ){ + for( int j = 0; j < declarations.length && declarations[j] != null; j++ ){ temp = declarations[j].getParameters()[i]; IASTName n = temp.getDeclarator().getName(); n.setBinding( binding ); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java index bc723df6d6d..1c28193542e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPMethod.java @@ -84,6 +84,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod { if( declarations != null ){ for( int i = 0; i < declarations.length; i++ ){ IASTDeclarator dtor = declarations[i]; + if (dtor == null) { + break; + } while( dtor.getParent() instanceof IASTDeclarator ) dtor = (IASTDeclarator) dtor.getParent(); IASTDeclaration decl = (IASTDeclaration) dtor.getParent();