[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43581] trunk/blender/source/blender/ editors: Better api use for paths.

Campbell Barton ideasman42 at gmail.com
Sat Jan 21 15:48:15 CET 2012


Revision: 43581
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43581
Author:   campbellbarton
Date:     2012-01-21 14:48:07 +0000 (Sat, 21 Jan 2012)
Log Message:
-----------
Better api use for paths.
Avoid possibly copy past buffer.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/space_file/filelist.c

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-21 11:15:01 UTC (rev 43580)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2012-01-21 14:48:07 UTC (rev 43581)
@@ -2474,7 +2474,7 @@
 	char *s, buf[512];
 	
 	s= buf;
-	if (title) s+= sprintf(s, "%s%%t|%s", title, item);
+	if (title) s+= BLI_snprintf(s, sizeof(buf), "%s%%t|%s", title, item);
 	(void)s;
 	
 	handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);

Modified: trunk/blender/source/blender/editors/space_file/filelist.c
===================================================================
--- trunk/blender/source/blender/editors/space_file/filelist.c	2012-01-21 11:15:01 UTC (rev 43580)
+++ trunk/blender/source/blender/editors/space_file/filelist.c	2012-01-21 14:48:07 UTC (rev 43581)
@@ -586,7 +586,7 @@
 
 void filelist_setdir(struct FileList* filelist, const char *dir)
 {
-	BLI_strncpy(filelist->dir, dir, FILE_MAX);
+	BLI_strncpy(filelist->dir, dir, sizeof(filelist->dir));
 }
 
 void filelist_imgsize(struct FileList* filelist, short w, short h)
@@ -853,10 +853,9 @@
 		for(num=0; num<filelist->numfiles; num++, file++) {
 			if(BLO_has_bfile_extension(file->relname)) {
 				char name[FILE_MAX];
-			
-				BLI_strncpy(name, filelist->dir, sizeof(name));
-				strcat(name, file->relname);
-				
+
+				BLI_join_dirfile(name, sizeof(name), filelist->dir, file->relname);
+
 				/* prevent current file being used as acceptable dir */
 				if (BLI_path_cmp(G.main->name, name) != 0) {
 					file->type &= ~S_IFMT;



More information about the Bf-blender-cvs mailing list