File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed
Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -180,12 +180,15 @@ fn native_pwd(
180180) -> JsResult < JsValue > {
181181 let mut buf = [ 0u8 ; 1024 ] ;
182182 match libbreenix:: process:: getcwd ( & mut buf) {
183- Ok ( len) => {
184- let path = core:: str:: from_utf8 ( & buf[ ..len] ) . unwrap_or ( "" ) ;
183+ Ok ( len) if len <= buf . len ( ) => {
184+ let path = core:: str:: from_utf8 ( & buf[ ..len] ) . unwrap_or ( "/ " ) ;
185185 let id = strings. intern ( path) ;
186186 Ok ( JsValue :: string ( id) )
187187 }
188- Err ( _) => Err ( JsError :: runtime ( "pwd: failed to get working directory" ) ) ,
188+ _ => {
189+ let id = strings. intern ( "/" ) ;
190+ Ok ( JsValue :: string ( id) )
191+ }
189192 }
190193}
191194
@@ -1588,7 +1591,7 @@ fn source_file(ctx: &mut Context, path: &str) {
15881591fn get_short_cwd ( ) -> Option < String > {
15891592 let mut buf = [ 0u8 ; 1024 ] ;
15901593 match libbreenix:: process:: getcwd ( & mut buf) {
1591- Ok ( len) => {
1594+ Ok ( len) if len <= buf . len ( ) => {
15921595 let cwd = std:: str:: from_utf8 ( & buf[ ..len] ) . ok ( ) ?;
15931596 if cwd == "/" {
15941597 Some ( String :: from ( "/" ) )
@@ -1597,7 +1600,7 @@ fn get_short_cwd() -> Option<String> {
15971600 cwd. rsplit ( '/' ) . next ( ) . map ( String :: from)
15981601 }
15991602 }
1600- Err ( _ ) => None ,
1603+ _ => None ,
16011604 }
16021605}
16031606
You can’t perform that action at this time.
0 commit comments