Skip to content

Commit f602c39

Browse files
committed
innodbchecksum: add fclose and handle errors
1 parent e7a89b4 commit f602c39

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

extra/innochecksum.cc

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -694,14 +694,14 @@ int main(int argc, char **argv)
694694
if (*filename == '\0')
695695
{
696696
fprintf(stderr, "Error; File name missing\n");
697-
goto error;
697+
goto error_out;
698698
}
699699

700700
/* stat the file to get size and page count */
701701
if (stat(filename, &st))
702702
{
703703
fprintf(stderr, "Error; %s cannot be found\n", filename);
704-
goto error;
704+
goto error_out;
705705
}
706706
size= st.st_size;
707707

@@ -711,15 +711,15 @@ int main(int argc, char **argv)
711711
{
712712
fprintf(stderr, "Error; %s cannot be opened", filename);
713713
perror(" ");
714-
goto error;
714+
goto error_out;
715715
}
716716

717717
big_buf = (unsigned char *)malloc(2 * UNIV_PAGE_SIZE_MAX);
718718
if (big_buf == NULL)
719719
{
720720
fprintf(stderr, "Error; failed to allocate memory\n");
721721
perror("");
722-
goto error;
722+
goto error_f;
723723
}
724724

725725
/* Make sure the page is aligned */
@@ -731,7 +731,7 @@ int main(int argc, char **argv)
731731
{
732732
fprintf(stderr, "Error; failed to allocate memory\n");
733733
perror("");
734-
return 1;
734+
goto error_big_buf;
735735
}
736736

737737
/* Make sure the page is aligned */
@@ -983,12 +983,17 @@ int main(int argc, char **argv)
983983
print_stats();
984984
free(big_xdes);
985985
free(big_buf);
986+
fclose(f);
986987
my_end(0);
987988
exit(0);
988989

989990
error:
990991
free(big_xdes);
992+
error_big_buf:
991993
free(big_buf);
994+
error_f:
995+
fclose(f);
996+
error_out:
992997
my_end(0);
993998
exit(1);
994999
}

0 commit comments

Comments
 (0)