mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
win_iconv: Fix some file handler leaks on exit
I realise this is a contradiction in terms, but it keeps code analysis tools happy. As spotted by cppcheck, which could not attend GUADEC, but sends everyone its best wishes anyway.
This commit is contained in:
parent
f1eeb7cf8c
commit
5707c91a56
@ -1989,6 +1989,7 @@ main(int argc, char **argv)
|
||||
size_t r;
|
||||
FILE *in = stdin;
|
||||
FILE *out = stdout;
|
||||
FILE *in_allocated = NULL, *out_allocated = NULL;
|
||||
int ignore = 0;
|
||||
char *p;
|
||||
|
||||
@ -2012,7 +2013,7 @@ main(int argc, char **argv)
|
||||
ignore = 1;
|
||||
else if (strcmp(argv[i], "--output") == 0)
|
||||
{
|
||||
out = fopen(argv[++i], "wb");
|
||||
out_allocated = out = fopen(argv[++i], "wb");
|
||||
if(out == NULL)
|
||||
{
|
||||
fprintf(stderr, "cannot open %s\n", argv[i]);
|
||||
@ -2021,7 +2022,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
in = fopen(argv[i], "rb");
|
||||
in_allocated = in = fopen(argv[i], "rb");
|
||||
if (in == NULL)
|
||||
{
|
||||
fprintf(stderr, "cannot open %s\n", argv[i]);
|
||||
@ -2086,6 +2087,11 @@ main(int argc, char **argv)
|
||||
|
||||
iconv_close(cd);
|
||||
|
||||
if (in_allocated != NULL)
|
||||
fclose (in_allocated);
|
||||
if (out_allocated != NULL)
|
||||
fclose (out_allocated);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user