On Tue, Nov 26, 2019 at 06:03:59PM +0900, Wang Shilong wrote: > @@ -725,12 +728,18 @@ static errcode_t calculate_tree(ext2_filsys fs, > return retval; > } > if (c3 == 0) { > + int delta1 = int_offset;; > + int delta2 = (char *)root - outdir->buf; > + > retval = alloc_blocks(fs, &limit, &int_ent, > &dx_ent, &int_offset, > NULL, outdir, i, &c2, > &c3); > if (retval) > return retval; > + /* outdir->buf might be reallocated */ > + int_limit = (struct ext2_dx_countlimit *)(outdir->buf + delta1); > + root = (struct ext2_dx_entry *)(outdir->buf + delta2); > > } > dx_ent->block = ext2fs_cpu_to_le32(i); Um, are you sure int delta1 = int_offset;; is correct? I would think int delta1 = (char *)int_limit - outdir->buf; is what is needed; it's certainly much more clear. - Ted