[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31270] trunk/blender/source/blender: bugfix [#23270] Long directory name segmentation fault in File brower

Campbell Barton ideasman42 at gmail.com
Thu Aug 12 02:14:32 CEST 2010


Revision: 31270
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31270
Author:   campbellbarton
Date:     2010-08-12 02:14:32 +0200 (Thu, 12 Aug 2010)

Log Message:
-----------
bugfix [#23270] Long directory name segmentation fault in File brower
 file->relname was being edited when its length allocated at the size of the original name, realloc'ing failed because the old string was still used by a button.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_file/file_draw.c
    trunk/blender/source/blender/editors/space_file/space_file.c
    trunk/blender/source/blender/makesdna/DNA_space_types.h

Modified: trunk/blender/source/blender/editors/space_file/file_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/file_draw.c	2010-08-11 22:36:46 UTC (rev 31269)
+++ trunk/blender/source/blender/editors/space_file/file_draw.c	2010-08-12 00:14:32 UTC (rev 31270)
@@ -426,21 +426,25 @@
 	SpaceFile *sfile= (SpaceFile*)CTX_wm_space_data(C);
 	ARegion* ar = CTX_wm_region(C);
 
+#if 0
 	struct direntry *file = (struct direntry *)arg1;
+#endif
 
 	BLI_make_file_string(G.sce, orgname, sfile->params->dir, oldname);
-	BLI_strncpy(filename, file->relname, sizeof(filename));
+	BLI_strncpy(filename, sfile->params->renameedit, sizeof(filename));
 	BLI_make_file_string(G.sce, newname, sfile->params->dir, filename);
 
 	if( strcmp(orgname, newname) != 0 ) {
 		if (!BLI_exists(newname)) {
 			BLI_rename(orgname, newname);
 			/* to make sure we show what is on disk */
+#if 0		/* this is cleared anyway, no need */
+			MEM_freeN(file->relname);
+			file->relname= BLI_strdup(sfile->params->renameedit);
+#endif
 			ED_fileselect_clear(C, sfile);
-		} else {
-			BLI_strncpy(file->relname, oldname, strlen(oldname)+1);
 		}
-		
+
 		ED_region_tag_redraw(ar);
 	}
 }
@@ -535,7 +539,7 @@
 			int but_width = (FILE_IMGDISPLAY == params->display) ? layout->tile_w : layout->column_widths[COLUMN_NAME];
 
 			uiBut *but = uiDefBut(block, TEX, 1, "", spos, sy-layout->tile_h-3, 
-				but_width, layout->textheight*2, file->relname, 1.0f, (float)FILE_MAX,0,0,"");
+				but_width, layout->textheight*2, sfile->params->renameedit, 1.0f, (float)sizeof(sfile->params->renameedit),0,0,"");
 			uiButSetRenameFunc(but, renamebutton_cb, file);
 			if ( 0 == uiButActiveOnly(C, block, but)) {
 				file->flags &= ~EDITING;

Modified: trunk/blender/source/blender/editors/space_file/space_file.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/space_file.c	2010-08-11 22:36:46 UTC (rev 31269)
+++ trunk/blender/source/blender/editors/space_file/space_file.c	2010-08-12 00:14:32 UTC (rev 31270)
@@ -232,6 +232,7 @@
 				file->flags |= EDITING;
 			}
 		}
+		BLI_strncpy(sfile->params->renameedit, sfile->params->renamefile, sizeof(sfile->params->renameedit));
 		params->renamefile[0] = '\0';
 	}
 	if (sfile->layout) sfile->layout->dirty= 1;

Modified: trunk/blender/source/blender/makesdna/DNA_space_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_space_types.h	2010-08-11 22:36:46 UTC (rev 31269)
+++ trunk/blender/source/blender/makesdna/DNA_space_types.h	2010-08-12 00:14:32 UTC (rev 31270)
@@ -161,6 +161,7 @@
 	char dir[240]; /* directory */
 	char file[80]; /* file */
 	char renamefile[80];
+	char renameedit[80]; /* annoying but the first is only used for initialization */
 
 	short type; /* XXXXX for now store type here, should be moved to the operator */
 	short flag; /* settings for filter, hiding dots files,...  */





More information about the Bf-blender-cvs mailing list