diff src/vdisk.c @ 157:dc4c7e7ec5c9

some free makes error on Linux
author kono
date Mon, 21 Jan 2019 01:00:29 +0900
parents 97a597b0afcd
children a4aa3ec95b75
line wrap: on
line diff
--- a/src/vdisk.c	Sun Jan 20 19:10:23 2019 +0900
+++ b/src/vdisk.c	Mon Jan 21 01:00:29 2019 +0900
@@ -21,7 +21,6 @@
 
 static int vdiskdebug = 0;  //   bit 1 trace, bit 2 filename
 
-
 Byte pmmu[8];  // process dat mmu
 
 extern char *prog ;   // for disass
@@ -95,7 +94,7 @@
     pd->fp = 0;
     pd->mode = 0;
     free(pd->dirfp); pd->dirfp = 0;
-    free(pd->name); pd->name = 0;
+    // free(pd->name); pd->name = 0;
 }
 
 /*
@@ -206,7 +205,9 @@
         while(*p==' ') p++;
     }
     char *name1 = addCurdir(name,pd,curdir);
-    if (name1!=name && path!=name) free(name);
+    if (name1!=name && path!=name) {
+       free(name);
+    }
     if (name1==0) return 0;
     pd->name = name1;
 if(vdiskdebug&2) {
@@ -382,9 +383,9 @@
 static int 
 filedescriptor(Byte *buf, int len, Byte *name,int curdir) {
     int err = 0x255;
-    PathDesc pd;  
+    PathDesc pd;  pd.name = 0;
     if (len<13) return -1;
-    checkFileName((char*)name,&pd,curdir);
+    if (checkFileName((char*)name,&pd,curdir)==0) goto err1;
     struct stat st;
     if (stat(pd.name,&st)!=0) goto err1;
     os9setmode(buf+FD_ATT,st.st_mode);
@@ -399,7 +400,7 @@
     os9setdate(buf+FD_Creat,&st.st_ctime);
     err = 0;
 err1:
-    free(pd.name);
+    // free(pd.name);     should be free
     return err;
 }
 
@@ -536,7 +537,7 @@
         case 0xd2:
             mode = *areg;
             attr = *breg;
-            pd->fp = 0;
+            pd->fp = 0; pd->name = 0;
             path = (char*)pmem(xreg);
             next = checkFileName(path,pd,curdir);
             *breg = 0xff;