diff --git a/expand.c b/expand.c index f0a973fda..8088e4577 100644 --- a/expand.c +++ b/expand.c @@ -1747,6 +1747,15 @@ int expand_string( void *context, al_truncate( out, 0 ); break; } + + case -1: + { + al_foreach( out, &free ); + al_destroy( in ); + al_destroy( out ); + return EXPAND_ERROR; + } + } } else diff --git a/wildcard.c b/wildcard.c index ffce98033..874b28707 100644 --- a/wildcard.c +++ b/wildcard.c @@ -447,6 +447,11 @@ int wildcard_expand( const wchar_t *wc, // debug( 3, L"WILDCARD_EXPAND %ls in %ls", wc, base_dir ); + if( reader_interrupted() ) + { + return -1; + } + if( !wc || !base_dir || !out) { debug( 2, L"Got null string on line %d of file %s", __LINE__, __FILE__ ); @@ -700,6 +705,7 @@ int wildcard_expand( const wchar_t *wc, struct stat buf; char *dir_str; int stat_res; + int new_res; wcscpy(&new_dir[base_len], name ); dir_str = wcs2str( new_dir ); @@ -735,10 +741,18 @@ int wildcard_expand( const wchar_t *wc, } } - res |= wildcard_expand( new_wc, - new_dir, - flags, - out ); + new_res = wildcard_expand( new_wc, + new_dir, + flags, + out ); + + if( new_res == -1 ) + { + res = -1; + break; + } + res |= new_res; + } /* @@ -746,10 +760,17 @@ int wildcard_expand( const wchar_t *wc, */ if( partial_match ) { - res |= wildcard_expand( wcschr( wc, ANY_STRING_RECURSIVE ), + new_res = wildcard_expand( wcschr( wc, ANY_STRING_RECURSIVE ), new_dir, flags | WILDCARD_RECURSIVE, out ); + if( new_res == -1 ) + { + res = -1; + break; + } + res |= new_res; + } } } diff --git a/wildcard.h b/wildcard.h index 9133b0fb8..39e8ce6d2 100644 --- a/wildcard.h +++ b/wildcard.h @@ -60,7 +60,7 @@ enum \param flags flags for the search. Can be any combination of ACCEPT_INCOMPLETE and EXECUTABLES_ONLY \param out The list in which to put the output - \return 1 if matches where found, 0 otherwise. + \return 1 if matches where found, 0 otherwise. Return -1 on abort (I.e. ^C was pressed). */ int wildcard_expand( const wchar_t *wc,