It should fix #2620 (and was not limited to windows only).
if( !psz_tmp )
return NULL;
- filename_sanitize( psz_tmp );
- if( asprintf( &psz_file, "%s"DIR_SEP"%s%s%s",
- psz_path, psz_tmp,
+ char *psz_tmp2 = filename_sanitize( psz_tmp );
+ free( psz_tmp );
+
+ if( !psz_tmp2 ||
+ asprintf( &psz_file, "%s"DIR_SEP"%s%s%s",
+ psz_path, psz_tmp2,
psz_extension ? "." : "",
psz_extension ? psz_extension : "" ) < 0 )
psz_file = NULL;
- free( psz_tmp );
+ free( psz_tmp2 );
return psz_file;
}
else