From 825017ddae48fc8af6ed5756b5c4a2ec9b144441 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Tue, 25 May 2010 17:16:48 +0000 Subject: [PATCH] Bug 314303: Protect against NPE. --- .../cdt/dsf/mi/service/CSourceLookup.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java index 65e1170f0cc..576cf71dd0f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2008 Wind River Systems and others. + * Copyright (c) 2007, 2010 Wind River Systems 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 @@ -82,13 +82,21 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup { for (int i = 0; i < containers.length; ++i) { if (containers[i] instanceof ProjectSourceContainer) { IProject project = ((ProjectSourceContainer)containers[i]).getProject(); - if (project != null && project.exists()) - list.add(project.getLocation().toPortableString()); + if (project != null && project.exists()) { + IPath location = project.getLocation(); + if (location != null) { + list.add(location.toPortableString()); + } + } } if (containers[i] instanceof FolderSourceContainer) { IContainer container = ((FolderSourceContainer)containers[i]).getContainer(); - if (container != null && container.exists()) - list.add(container.getLocation().toPortableString()); + if (container != null && container.exists()) { + IPath location = container.getLocation(); + if (location != null) { + list.add(location.toPortableString()); + } + } } if (containers[i] instanceof DirectorySourceContainer) { File dir = ((DirectorySourceContainer)containers[i]).getDirectory();