Check results of fopen.

Check results of fopen.
This commit is contained in:
Robert Norris 1998-05-20 10:20:01 +00:00
parent c7b0ae2571
commit f57c14f15a
2 changed files with 18 additions and 4 deletions

View File

@ -21,6 +21,7 @@
/* this is almost exactly the same as the gz(ip) plugin by */
/* Dan Risacher & Josh, so feel free to go look there. */
/* GZ plugin adapted to BZ2 by Adam. I've left all other */
/* Error checking added by srn. */
/* credits intact since it was only a super-wussy mod. */
/* This is reads and writes bzip2ed image files for the Gimp
@ -250,7 +251,10 @@ save_image (char *filename,
else if (pid == 0)
{
f = fopen(filename,"w");
if (!(f = fopen(filename,"w"))){
g_warning("bz2: fopen failed: %s\n", g_strerror(errno));
_exit(127);
}
/* make stdout for this process be the output file */
if (-1 == dup2(fileno(f),fileno(stdout)))
@ -307,7 +311,10 @@ load_image (char *filename, gint32 run_mode)
else if (pid == 0) /* child process */
{
FILE* f;
f = fopen(tmpname,"w");
if (!(f = fopen(tmpname,"w"))){
g_warning("bz2: fopen failed: %s\n", g_strerror(errno));
_exit(127);
}
/* make stdout for this child process be the temp file */
if (-1 == dup2(fileno(f),fileno(stdout)))

View File

@ -21,6 +21,7 @@
/* this is almost exactly the same as the gz(ip) plugin by */
/* Dan Risacher & Josh, so feel free to go look there. */
/* GZ plugin adapted to BZ2 by Adam. I've left all other */
/* Error checking added by srn. */
/* credits intact since it was only a super-wussy mod. */
/* This is reads and writes bzip2ed image files for the Gimp
@ -250,7 +251,10 @@ save_image (char *filename,
else if (pid == 0)
{
f = fopen(filename,"w");
if (!(f = fopen(filename,"w"))){
g_warning("bz2: fopen failed: %s\n", g_strerror(errno));
_exit(127);
}
/* make stdout for this process be the output file */
if (-1 == dup2(fileno(f),fileno(stdout)))
@ -307,7 +311,10 @@ load_image (char *filename, gint32 run_mode)
else if (pid == 0) /* child process */
{
FILE* f;
f = fopen(tmpname,"w");
if (!(f = fopen(tmpname,"w"))){
g_warning("bz2: fopen failed: %s\n", g_strerror(errno));
_exit(127);
}
/* make stdout for this child process be the temp file */
if (-1 == dup2(fileno(f),fileno(stdout)))