@@ -470,33 +470,29 @@ static void
470470imageinfo_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}
0 commit comments