Description
The Windows implementation of getSymbol in ort/library_windows.go uses an unnecessary double conversion through unsafe.Pointer that is error-prone.
Current Code
File: ort/library_windows.go:24
func getSymbol(handle uintptr, symbol string) (uintptr, error) {
proc, err := windows.GetProcAddress(windows.Handle(handle), symbol)
if err != nil {
return 0, err
}
return uintptr(unsafe.Pointer(proc)), nil // Double conversion
}
Issue
The double conversion uintptr(unsafe.Pointer(proc)) is unnecessary because:
windows.GetProcAddress returns *byte
- This can be converted directly to
uintptr
- The intermediate
unsafe.Pointer step adds no safety
Proposed Fix
func getSymbol(handle uintptr, symbol string) (uintptr, error) {
proc, err := windows.GetProcAddress(windows.Handle(handle), symbol)
if err != nil {
return 0, err
}
// Direct conversion - GetProcAddress returns *byte which is uintptr-compatible
return uintptr(proc), nil
}
Impact
- Severity: Low (current code works, but is unnecessarily complex)
- Priority: Medium (should fix before v1.0)
- Risk: Minimal (simplification of existing working code)
Testing
- Verify Windows builds still compile
- Run existing tests on Windows platform
- No behavior change expected
Related
Acceptance Criteria
Description
The Windows implementation of
getSymbolinort/library_windows.gouses an unnecessary double conversion throughunsafe.Pointerthat is error-prone.Current Code
File:
ort/library_windows.go:24Issue
The double conversion
uintptr(unsafe.Pointer(proc))is unnecessary because:windows.GetProcAddressreturns*byteuintptrunsafe.Pointerstep adds no safetyProposed Fix
Impact
Testing
Related
Acceptance Criteria
unsafe.Pointerintermediate conversion