img: Fix fd leaks
Spotted by maddin200@aol.com https://bugs.freedesktop.org/show_bug.cgi?id=90197
This commit is contained in:
parent
391f77ce5e
commit
55b83062d0
1 changed files with 2 additions and 0 deletions
|
@ -166,12 +166,14 @@ API_EXPORTED int fp_img_save_to_file(struct fp_img *img, char *path)
|
||||||
|
|
||||||
r = fprintf(fd, "P5 %d %d 255\n", img->width, img->height);
|
r = fprintf(fd, "P5 %d %d 255\n", img->width, img->height);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
fclose(fd);
|
||||||
fp_err("pgm header write failed, error %d", r);
|
fp_err("pgm header write failed, error %d", r);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = fwrite(img->data, 1, write_size, fd);
|
r = fwrite(img->data, 1, write_size, fd);
|
||||||
if (r < write_size) {
|
if (r < write_size) {
|
||||||
|
fclose(fd);
|
||||||
fp_err("short write (%d)", r);
|
fp_err("short write (%d)", r);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue