Clenup: Text Editor: Fix inconsistencies in textline handling (makes coverty happy).
authorBastien Montagne <montagne29@wanadoo.fr>
Sun, 4 Oct 2015 06:59:14 +0000 (08:59 +0200)
committerBastien Montagne <montagne29@wanadoo.fr>
Sun, 4 Oct 2015 07:00:59 +0000 (09:00 +0200)
source/blender/editors/space_text/text_ops.c

index 060bf241bcff5db02800ee48a7e8231b9da913a7..948293d150b1e459ae3649256212b26b40a1948c 100644 (file)
@@ -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;