e2fsck: notice when the realloc of dir_info fails

If the reallocation of dir_info fails, we will eventually cause e2fsck
to fail with an internal error.  So if the realloc fails, print a
message and bail out with a fatal error early when at the time of the
reallocation failure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
test-maint
Theodore Ts'o 2014-09-11 12:24:07 -04:00
parent 8a54677711
commit e9a5c6e360
2 changed files with 8 additions and 0 deletions

View File

@ -140,6 +140,10 @@ void e2fsck_add_dir_info(e2fsck_t ctx, ext2_ino_t ino, ext2_ino_t parent)
sizeof(struct dir_info),
&ctx->dir_info->array);
if (retval) {
fprintf(stderr, "Couldn't reallocate dir_info "
"structure to %d entries\n",
ctx->dir_info->size);
fatal_error(ctx, 0);
ctx->dir_info->size -= 10;
return;
}

View File

@ -40,6 +40,10 @@ void e2fsck_add_dx_dir(e2fsck_t ctx, ext2_ino_t ino, int num_blocks)
sizeof(struct dx_dir_info),
&ctx->dx_dir_info);
if (retval) {
fprintf(stderr, "Couldn't reallocate dx_dir_info "
"structure to %d entries\n",
ctx->dx_dir_info_size);
fatal_error(ctx, 0);
ctx->dx_dir_info_size -= 10;
return;
}