| ... | @@ -31,7 +31,7 @@ pub const DynLib = struct { | ... | @@ -31,7 +31,7 @@ pub const DynLib = struct { |
| 31 | | 31 | |
| 32 | /// Trusts the file. Malicious file will be able to execute arbitrary code. | 32 | /// Trusts the file. Malicious file will be able to execute arbitrary code. |
| 33 | pub fn openZ(path_c: [*:0]const u8) Error!DynLib { | 33 | pub fn openZ(path_c: [*:0]const u8) Error!DynLib { |
| 34 | return .{ .inner = try InnerType.open(path_c) }; | 34 | return .{ .inner = try InnerType.openZ(path_c) }; |
| 35 | } | 35 | } |
| 36 | | 36 | |
| 37 | /// Trusts the file. | 37 | /// Trusts the file. |
| ... | @@ -376,7 +376,7 @@ pub const WindowsDynLib = struct { | ... | @@ -376,7 +376,7 @@ pub const WindowsDynLib = struct { |
| 376 | /// WindowsDynLib specific | 376 | /// WindowsDynLib specific |
| 377 | /// Opens dynamic library with specified library loading flags. | 377 | /// Opens dynamic library with specified library loading flags. |
| 378 | pub fn openExZ(path_c: [*:0]const u8, flags: windows.LoadLibraryFlags) Error!WindowsDynLib { | 378 | pub fn openExZ(path_c: [*:0]const u8, flags: windows.LoadLibraryFlags) Error!WindowsDynLib { |
| 379 | const path_w = try windows.cStrToPrefixedFileW(null, path_c); | 379 | const path_w = windows.cStrToPrefixedFileW(null, path_c) catch return error.InvalidPath; |
| 380 | return openExW(path_w.span().ptr, flags); | 380 | return openExW(path_w.span().ptr, flags); |
| 381 | } | 381 | } |
| 382 | | 382 | |
| ... | @@ -466,4 +466,5 @@ test "dynamic_library" { | ... | @@ -466,4 +466,5 @@ test "dynamic_library" { |
| 466 | }; | 466 | }; |
| 467 | | 467 | |
| 468 | try testing.expectError(error.FileNotFound, DynLib.open(libname)); | 468 | try testing.expectError(error.FileNotFound, DynLib.open(libname)); |
| | 469 | try testing.expectError(error.FileNotFound, DynLib.openZ(libname.ptr)); |
| 469 | } | 470 | } |