Revision: 15220
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=15220
Author:   campbellbarton
Date:     2008-06-14 18:54:46 +0200 (Sat, 14 Jun 2008)

Log Message:
-----------
bugfix for memory corruption caused by BLI_cleanup_file on paths that went too 
far back.
/a/b/../../../ - problematic
/a/b/c/../../../ - ok
Also got rid of warnings in shadbuf.c with GET_INT_FROM_POINTER

Modified Paths:
--------------
    trunk/blender/source/blender/blenlib/intern/util.c
    trunk/blender/source/blender/render/intern/source/shadbuf.c

Modified: trunk/blender/source/blender/blenlib/intern/util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/util.c  2008-06-14 03:00:38 UTC 
(rev 15219)
+++ trunk/blender/source/blender/blenlib/intern/util.c  2008-06-14 16:54:46 UTC 
(rev 15220)
@@ -905,8 +905,11 @@
                        if (dir[a] == '\\') break;
                        a--;
                }
-               memmove( dir+a, eind, strlen(eind)+1 );
-               
+               if (a<0) {
+                       break;
+               } else {
+                       memmove( dir+a, eind, strlen(eind)+1 );
+               }
        }
 
        while ( (start = strstr(dir,"\\.\\")) ){
@@ -939,7 +942,11 @@
                        if (dir[a] == '/') break;
                        a--;
                }
-               memmove( dir+a, eind, strlen(eind)+1 );
+               if (a<0) {
+                       break;
+               } else {
+                       memmove( dir+a, eind, strlen(eind)+1 );
+               }
        }
 
        while ( (start = strstr(dir,"/./")) ){
@@ -1128,8 +1135,8 @@
        char vol[3] = {'\0', '\0', '\0'};
 
        BLI_strncpy(vol, path, 3);
-       wasrelative= (strncmp(vol, "//", 2)==0);
-
+       wasrelative= (vol[0]=='/' && vol[1]=='/');
+       
 #ifdef WIN32
        /* we are checking here if we have an absolute path that is not in the 
current
           blend file as a lib main - we are basically checking for the case 
that a 
@@ -1166,7 +1173,7 @@
 
        /* Paths starting with // will get the blend file as their base,
         * this isnt standard in any os but is uesed in blender all over the 
place */
-       if (tmp[0] == '/' && tmp[1] == '/') {
+       if (wasrelative) {
                char *lslash= BLI_last_slash(base);
                if (lslash) {
                        int baselen= (int) (lslash-base) + 1;

Modified: trunk/blender/source/blender/render/intern/source/shadbuf.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/shadbuf.c 2008-06-14 
03:00:38 UTC (rev 15219)
+++ trunk/blender/source/blender/render/intern/source/shadbuf.c 2008-06-14 
16:54:46 UTC (rev 15220)
@@ -636,7 +636,7 @@
        else {
                /* got warning on this for 64 bits.... */
                /* but it's working code! in this case rz is not a pointer but 
zvalue (ton) */
-               zsamp= (int) rz;
+               zsamp= GET_INT_FROM_POINTER(rz);
        }
 
        /* tricky stuff here; we use ints which can overflow easily with bias 
values */
@@ -816,7 +816,7 @@
        else {
                /* same as before */
                /* still working code! (ton) */
-               zsamp= (int) rz;
+               zsamp= GET_INT_FROM_POINTER(rz);
        }
 
        /* NO schadow when sampled at 'eternal' distance */


_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to