@@ -258,7 +258,9 @@ impl DevicePathFromTextProtocol {
258258        str_to_utf16_ptr ( path) 
259259            . map ( |utf16_str| { 
260260                let  out = unsafe  {  & * ( ( self . text_to_device_path_node ) ( utf16_str) )  } ; 
261-                 :: get_system_table ( ) . boot_services ( ) . free_pool ( utf16_str) ; 
261+                 // FIXME(csssuf) 
262+                 // Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems 
263+                 // to hang here for unknown reasons. So we leak it. 
262264                out
263265            } ) 
264266    } 
@@ -267,7 +269,9 @@ impl DevicePathFromTextProtocol {
267269        str_to_utf16_ptr ( path) 
268270            . map ( |utf16_str| { 
269271                let  out = unsafe  {  & * ( ( self . text_to_device_path ) ( utf16_str) )  } ; 
270-                 :: get_system_table ( ) . boot_services ( ) . free_pool ( utf16_str) ; 
272+                 // FIXME(csssuf) 
273+                 // Ideally, at this point, we'd free utf16_str. However, free_pool(utf16_str) seems 
274+                 // to hang here for unknown reasons. So we leak it. 
271275                out
272276            } ) 
273277    } 
@@ -278,7 +282,7 @@ pub struct DevicePathUtilitiesProtocol {
278282    get_device_path_size :  * const  CVoid , 
279283    duplicate_device_path :  * const  CVoid , 
280284    append_device_path :  unsafe  extern  "win64"  fn ( src1 :  * const  DevicePathProtocol ,  src2 :  * const  DevicePathProtocol )  -> * const  DevicePathProtocol , 
281-     append_device_node :  * const  CVoid , 
285+     append_device_node :  unsafe   extern   "win64"   fn ( path :   * const  DevicePathProtocol ,   node :   * const   DevicePathProtocol )  ->  * const   DevicePathProtocol , 
282286    append_device_path_instance :  * const  CVoid , 
283287    get_next_device_path_instance :  * const  CVoid , 
284288    is_device_path_multi_instance :  * const  CVoid , 
@@ -296,7 +300,23 @@ impl DevicePathUtilitiesProtocol {
296300        unsafe  { 
297301            let  out = ( self . append_device_path ) ( src1,  src2) ; 
298302            if  out == 0  as  * const  DevicePathProtocol  { 
299-                 return  Err ( Status :: InvalidParameter ) ; 
303+                 // `out` being a null pointer indicates, according to the spec, that "memory could 
304+                 // not be allocate[sic]." Whether that's due to memory conditions, bad parameters 
305+                 // being passed in, or another reason is unspecified. Unless the caller passes in 
306+                 // a massive DevicePathProtocol, it's unlikely that it's due to the actual 
307+                 // parameters, so error here is represented as OutOfResources. 
308+                 return  Err ( Status :: OutOfResources ) ; 
309+             } 
310+             Ok ( out) 
311+         } 
312+     } 
313+ 
314+     pub  fn  append_device_node ( & self ,  path :  * const  DevicePathProtocol ,  node :  * const  DevicePathProtocol )  -> Result < * const  DevicePathProtocol ,  Status >  { 
315+         unsafe  { 
316+             let  out = ( self . append_device_node ) ( path,  node) ; 
317+             if  out == 0  as  * const  DevicePathProtocol  { 
318+                 // See comment in append_device_path. 
319+                 return  Err ( Status :: OutOfResources ) ; 
300320            } 
301321            Ok ( out) 
302322        } 
0 commit comments