[geany/geany] 6a0673: TM: Don't allow passing NULL to tm_workspace API

Colomban Wendling git-noreply at xxxxx
Sat Nov 8 17:32:41 UTC 2014


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 08 Nov 2014 17:32:41 UTC
Commit:      6a0673f4ae8d18ada42afb7f3df46929f540cc3f
             https://github.com/geany/geany/commit/6a0673f4ae8d18ada42afb7f3df46929f540cc3f

Log Message:
-----------
TM: Don't allow passing NULL to tm_workspace API


Modified Paths:
--------------
    src/dialogs.c
    src/document.c
    tagmanager/src/tm_workspace.c

Modified: src/dialogs.c
11 lines changed, 7 insertions(+), 4 deletions(-)
===================================================================
@@ -501,10 +501,13 @@ static gboolean handle_save_as(const gchar *utf8_filename, gboolean rename_file)
 		{
 			document_rename_file(doc, utf8_filename);
 		}
-		/* create a new tm_source_file object otherwise tagmanager won't work correctly */
-		tm_workspace_remove_source_file(doc->tm_file);
-		tm_source_file_free(doc->tm_file);
-		doc->tm_file = NULL;
+		if (doc->tm_file)
+		{
+			/* create a new tm_source_file object otherwise tagmanager won't work correctly */
+			tm_workspace_remove_source_file(doc->tm_file);
+			tm_source_file_free(doc->tm_file);
+			doc->tm_file = NULL;
+		}
 	}
 	success = document_save_file_as(doc, utf8_filename);
 


Modified: src/document.c
7 lines changed, 5 insertions(+), 2 deletions(-)
===================================================================
@@ -714,8 +714,11 @@ static gboolean remove_page(guint page_num)
 	g_free(doc->priv->saved_encoding.encoding);
 	g_free(doc->file_name);
 	g_free(doc->real_path);
-	tm_workspace_remove_source_file(doc->tm_file);
-	tm_source_file_free(doc->tm_file);
+	if (doc->tm_file)
+	{
+		tm_workspace_remove_source_file(doc->tm_file);
+		tm_source_file_free(doc->tm_file);
+	}
 
 	if (doc->priv->tag_tree)
 		gtk_widget_destroy(doc->priv->tag_tree);


Modified: tagmanager/src/tm_workspace.c
13 lines changed, 8 insertions(+), 5 deletions(-)
===================================================================
@@ -202,9 +202,8 @@ void tm_workspace_update_source_file_buffer(TMSourceFile *source_file, guchar* t
 void tm_workspace_remove_source_file(TMSourceFile *source_file)
 {
 	guint i;
-	
-	if (!source_file)
-		return;
+
+	g_return_if_fail(source_file != NULL);
 
 	for (i=0; i < theWorkspace->source_files->len; ++i)
 	{
@@ -270,7 +269,9 @@ static void tm_workspace_update(void)
 void tm_workspace_add_source_files(GPtrArray *source_files)
 {
 	guint i;
-	
+
+	g_return_if_fail(source_files != NULL);
+
 	for (i = 0; i < source_files->len; i++)
 	{
 		TMSourceFile *source_file = source_files->pdata[i];
@@ -292,7 +293,9 @@ void tm_workspace_add_source_files(GPtrArray *source_files)
 void tm_workspace_remove_source_files(GPtrArray *source_files)
 {
 	guint i, j;
-	
+
+	g_return_if_fail(source_files != NULL);
+
 	//TODO: sort both arrays by pointer value and remove in single pass
 	for (i = 0; i < source_files->len; i++)
 	{



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list