Skip to content

Commit 3be5a86

Browse files
committed
be more careful about deleting temps
1 parent f02aba9 commit 3be5a86

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ started 8.3.1 on 19/5/16
22
- disable debug by default, thanks Benjamin
33
- configure changes to help win64
44
- fix middle-drag in ws and image view
5+
- be more careful about deleting temp files
56

67
started 8.3.0 on 28/3/16
78
- move path search stuff into _convert from _magick

src/imageinfo.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,33 +470,29 @@ static void
470470
imageinfo_finalize( GObject *gobject )
471471
{
472472
Imageinfo *imageinfo = IMAGEINFO( gobject );
473-
gboolean isfile = imageinfo->im ? im_isfile( imageinfo->im ) : FALSE;
474-
char name[FILENAME_MAX];
473+
gboolean isfile = imageinfo->im && im_isfile( imageinfo->im );
475474

476475
#ifdef DEBUG_MAKE
477476
printf( "imageinfo_finalize:" );
478477
imageinfo_print( imageinfo );
479478
#endif /*DEBUG_MAKE*/
480479

481-
if( imageinfo->dfile && isfile ) {
482-
/* We must close before we delete ... save the filename.
483-
*/
484-
im_strncpy( name, imageinfo->im->filename, FILENAME_MAX - 5 );
480+
IM_FREEF( im_close, imageinfo->im );
481+
IM_FREEF( im_close, imageinfo->mapped_im );
482+
IM_FREEF( im_close, imageinfo->identity_lut );
485483

484+
if( imageinfo->dfile &&
485+
imageinfo->delete_filename &&
486+
isfile ) {
486487
#ifdef DEBUG_OPEN
487488
printf( "imageinfo_destroy: unlinking \"%s\"\n", name );
488489
#endif /*DEBUG_OPEN*/
489-
}
490-
491-
IM_FREEF( im_close, imageinfo->im );
492-
IM_FREEF( im_close, imageinfo->mapped_im );
493-
IM_FREEF( im_close, imageinfo->identity_lut );
494490

495-
if( imageinfo->dfile && isfile ) {
496-
unlinkf( "%s", name );
491+
unlinkf( "%s", imageinfo->delete_filename );
497492
iobject_changed( IOBJECT( main_imageinfogroup ) );
498493
}
499494

495+
VIPS_FREE( imageinfo->delete_filename );
500496
MANAGED_UNREF( imageinfo->underlying );
501497

502498
imageinfo_undo_free( imageinfo );
@@ -626,6 +622,7 @@ imageinfo_init( Imageinfo *imageinfo )
626622
imageinfo->proxy = NULL;
627623

628624
imageinfo->dfile = FALSE;
625+
imageinfo->delete_filename = NULL;
629626
imageinfo->from_file = FALSE;
630627
imageinfo->mtime = 0;
631628
imageinfo->exprs = NULL;
@@ -812,6 +809,7 @@ imageinfo_new_temp( Imageinfogroup *imageinfogroup,
812809
return( NULL );
813810
}
814811
imageinfo->dfile = TRUE;
812+
VIPS_SETSTR( imageinfo->delete_filename, tname );
815813

816814
return( imageinfo );
817815
}

src/imageinfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ struct _Imageinfo {
121121
Imageinfoproxy *proxy; /* Proxy for IMAGE callbacks */
122122

123123
gboolean dfile; /* delete_file on final close */
124+
char *delete_filename; /* and the file we delete */
124125

125126
gboolean from_file; /* Set if ->name is a user file */
126127
time_t mtime; /* What mtime was when we loaded this file */

0 commit comments

Comments
 (0)