# github.com/tdewolff/minify/v2/bindings/js
bindings/js/minify.go:28:12: invalid array length 1 << 32 (untyped int constant 4294967296)
bindings/js/minify.go:37:12: invalid array length 1 << 32 (untyped int constant 4294967296)
# github.com/tdewolff/minify/v2/bindings/py
bindings/py/minify.go:28:12: invalid array length 1 << 32 (untyped int constant 4294967296)
bindings/py/minify.go:37:12: invalid array length 1 << 32 (untyped int constant 4294967296)
--- /bindings/py/minify.go
+++ /bindings/py/minify.go
@@ -25,7 +25,10 @@
}
func goBytes(str *C.char, length C.longlong) []byte {
- return (*[1 << 32]byte)(unsafe.Pointer(str))[:length:length]
+ unsafePtr := unsafe.Pointer(str)
+ byteSlice := unsafe.Slice((*byte)(unsafePtr), length)
+
+ return byteSlice
}
func goStringArray(carr **C.char, length C.longlong) []string {
@@ -34,11 +37,12 @@
}
strs := make([]string, length)
- arr := (*[1 << 32]*C.char)(unsafe.Pointer(carr))[:length:length]
for i := 0; i < int(length); i++ {
- strs[i] = C.GoString(arr[i])
+ cstr := *(**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(carr)) + uintptr(i)*unsafe.Sizeof(*carr)))
+ strs[i] = C.GoString(cstr)
}
return strs
+
}
//export minifyConfig
--- /bindings/js/minify.go
+++ /bindings/js/minify.go
@@ -25,7 +25,11 @@
}
func goBytes(str *C.char, length C.longlong) []byte {
- return (*[1 << 32]byte)(unsafe.Pointer(str))[:length:length]
+ unsafePtr := unsafe.Pointer(str)
+ byteSlice := unsafe.Slice((*byte)(unsafePtr), length)
+
+ return byteSlice
+
}
func goStringArray(carr **C.char, length C.longlong) []string {
@@ -34,11 +38,13 @@
}
strs := make([]string, length)
- arr := (*[1 << 32]*C.char)(unsafe.Pointer(carr))[:length:length]
for i := 0; i < int(length); i++ {
- strs[i] = C.GoString(arr[i])
+ cstr := *(**C.char)(unsafe.Pointer(uintptr(unsafe.Pointer(carr)) + uintptr(i)*unsafe.Sizeof(*carr)))
+ strs[i] = C.GoString(cstr)
}
+
return strs
+
}
//export minifyConfig
Hello,
I was updating the minify package in the Alpine Linux repos from 1.20.24 to 1.20.28 when I noticed that most if not all 32bit systems failed (log: https://gitlab.alpinelinux.org/Misthios/aports/-/jobs/1394860 ) with the same error:
I have made some changes to those file to get the build passing (log: https://gitlab.alpinelinux.org/Misthios/aports/-/jobs/1395003 ).
But since those changed are untested since I do not use those bindings.
Here are the changes: