[gnome-builder] libide: add more stringent check when creating location



commit 7bc3bf2ebd363238b34cdc45de088a6f8fbcef91
Author: Christian Hergert <christian hergert me>
Date:   Sun Mar 1 23:38:02 2015 -0800

    libide: add more stringent check when creating location

 libide/clang/ide-clang-translation-unit.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
---
diff --git a/libide/clang/ide-clang-translation-unit.c b/libide/clang/ide-clang-translation-unit.c
index ca1550a..29beb37 100644
--- a/libide/clang/ide-clang-translation-unit.c
+++ b/libide/clang/ide-clang-translation-unit.c
@@ -147,12 +147,14 @@ create_location (IdeClangTranslationUnit *self,
   IdeFile *file = NULL;
   CXFile cxfile = NULL;
   g_autofree gchar *path = NULL;
+  const gchar *cstr;
   CXString str;
   unsigned line;
   unsigned column;
   unsigned offset;
 
   g_return_val_if_fail (self, NULL);
+  g_return_val_if_fail (workpath, NULL);
 
   clang_getFileLocation (cxloc, &cxfile, &line, &column, &offset);
 
@@ -160,7 +162,11 @@ create_location (IdeClangTranslationUnit *self,
   if (column > 0) column--;
 
   str = clang_getFileName (cxfile);
-  path = get_path (workpath, clang_getCString (str));
+  cstr = clang_getCString (str);
+  if (!cstr)
+    return NULL;
+
+  path = get_path (workpath, cstr);
   clang_disposeString (str);
 
   file = ide_project_get_file_for_path (project, path);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]