[Bf-blender-cvs] [6121854] master: Clenup: Text Editor: Fix inconsistencies in textline handling (makes coverty happy).

Bastien Montagne noreply at git.blender.org
Sun Oct 4 09:01:11 CEST 2015


Commit: 61218546cb79dbae09a6102a5695878ea96d0045
Author: Bastien Montagne
Date:   Sun Oct 4 08:59:14 2015 +0200
Branches: master
https://developer.blender.org/rB61218546cb79dbae09a6102a5695878ea96d0045

Clenup: Text Editor: Fix inconsistencies in textline handling (makes coverty happy).

===================================================================

M	source/blender/editors/space_text/text_ops.c

===================================================================

diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c
index 060bf24..948293d 100644
--- a/source/blender/editors/space_text/text_ops.c
+++ b/source/blender/editors/space_text/text_ops.c
@@ -1062,16 +1062,17 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
 	for (tmp = text->lines.first; tmp; tmp = tmp->next) {
 		char *new_line;
 
+		BLI_assert(tmp->line);
+
 		flatten_string(st, &fs, tmp->line);
 		new_line = BLI_strdup(fs.buf);
 		flatten_string_free(&fs);
 
-		/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
-		if (tmp->line)
-			MEM_freeN(tmp->line);
+		MEM_freeN(tmp->line);
 		if (tmp->format)
 			MEM_freeN(tmp->format);
 		
+		/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
 		tmp->line = new_line;
 		tmp->len = strlen(new_line);
 		tmp->format = NULL;
@@ -1089,6 +1090,8 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
 			char *tmp_line_cur = tmp_line;
 			const size_t tab_len = st->tabnumber;
 
+			BLI_assert(text_check_line);
+
 			for (a = 0; a < text_check_line_len;) {
 				/* A tab can only start at a position multiple of tab_len... */
 				if (!(a % tab_len) && (text_check_line[a] == ' ')) {
@@ -1135,12 +1138,11 @@ static int text_convert_whitespace_exec(bContext *C, wmOperator *op)
 				flatten_string_free(&fs);
 #endif
 
-				/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
-				if (tmp->line)
-					MEM_freeN(tmp->line);
+				MEM_freeN(tmp->line);
 				if (tmp->format)
 					MEM_freeN(tmp->format);
 
+				/* Put new_line in the tmp->line spot still need to try and set the curc correctly. */
 				tmp->line = BLI_strdup(tmp_line);
 				tmp->len = strlen(tmp_line);
 				tmp->format = NULL;




More information about the Bf-blender-cvs mailing list