]> Zhao Yanbai Git Server - minix.git/commitdiff
Fix MFS ftruncate crash (Bug#370, reported by Aki Goto)
authorDavid van Moolenbroek <david@minix3.org>
Thu, 24 Dec 2009 23:43:16 +0000 (23:43 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Thu, 24 Dec 2009 23:43:16 +0000 (23:43 +0000)
servers/mfs/write.c

index 797a6e45d9bd76b16cd43a893f4aa863abce36a2..3bac78cb926135060cd9f748860ca7d1b2c15df7 100644 (file)
@@ -166,10 +166,10 @@ int op;                           /* special actions */
   }
 
   /* If the single indirect block isn't there (or was just freed),
-   * see if we have to keep the double indirect block.
+   * see if we have to keep the double indirect block, if any.
    */
-  if(z1 == NO_ZONE && !single && empty_indir(bp_dindir, rip->i_sp) &&
-     z2 != NO_ZONE) {
+  if(z1 == NO_ZONE && !single && z2 != NO_ZONE &&
+     empty_indir(bp_dindir, rip->i_sp)) {
        free_zone(rip->i_dev, z2);
        rip->i_zone[zones+1] = NO_ZONE;
   }