Skip to content

Commit

Permalink
Merge pull request #49 from mappu/miqt-fix-malloc
Browse files Browse the repository at this point in the history
Fix buffer overflow regression with QStringList
  • Loading branch information
mappu authored Oct 19, 2024
2 parents b034456 + 0204e2f commit 7527c79
Show file tree
Hide file tree
Showing 33 changed files with 201 additions and 183 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/miqt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ jobs:
path: ~/.cache/go-build
key: linux64-gocache

- name: Linux64 bindings compile
run: docker run -v ~/.cache/go-build:/root/.cache/go-build -v $PWD:/src -w /src miqt/linux64:latest /bin/bash -c 'cd qt && go build'
- name: Linux64 bindings compile and test
run: docker run -v ~/.cache/go-build:/root/.cache/go-build -v $PWD:/src -w /src miqt/linux64:latest /bin/bash -c 'cd qt && go build && cd ../examples/marshalling && env QT_QPA_PLATFORM=offscreen go test -v'

miqt_win64:
runs-on: ubuntu-22.04
Expand Down
13 changes: 11 additions & 2 deletions cmd/genbindings/emitgo.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,17 @@ func (gfs *goFileState) emitParameterGo2CABIForwarding(p CppParameter) (preamble
gfs.imports["runtime"] = struct{}{}
gfs.imports["unsafe"] = struct{}{}

preamble += "// For the C ABI, malloc a C array of raw pointers\n"
preamble += nameprefix + "_CArray := (*[0xffff]" + listType.parameterTypeCgo() + ")(C.malloc(C.size_t(8 * len(" + p.ParameterName + "))))\n"
var mallocSize string
if listType.ParameterType == "QString" || listType.ParameterType == "QByteArray" {
preamble += "// For the C ABI, malloc a C array of structs\n"
mallocSize = "int(unsafe.Sizeof(C.struct_miqt_string{}))"

} else {
preamble += "// For the C ABI, malloc a C array of raw pointers\n"
mallocSize = "8"
}

preamble += nameprefix + "_CArray := (*[0xffff]" + listType.parameterTypeCgo() + ")(C.malloc(C.size_t(" + mallocSize + " * len(" + p.ParameterName + "))))\n"
preamble += "defer C.free(unsafe.Pointer(" + nameprefix + "_CArray))\n"

preamble += "for i := range " + p.ParameterName + "{\n"
Expand Down
15 changes: 12 additions & 3 deletions examples/marshalling/marshalling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import (
"github.com/mappu/miqt/qt"
)

func TestMarshalling(t *testing.T) {

qt.NewQApplication(os.Args)
func testMarshalling(t *testing.T) {

// Bool
t.Run("Bool", func(t *testing.T) {
Expand Down Expand Up @@ -107,5 +105,16 @@ func TestMarshalling(t *testing.T) {
}

})
}

func TestMarshalling(t *testing.T) {

qt.NewQApplication(os.Args)

// In case of heap corruption, run the whole test multiple times.

for i := 0; i < 5; i++ {
testMarshalling(t)
}

}
4 changes: 2 additions & 2 deletions qt/gen_qcborarray.go
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,8 @@ func (this *QCborArray) OperatorShiftLeft(v *QCborValue) *QCborArray {
}

func QCborArray_FromStringList(list []string) *QCborArray {
// For the C ABI, malloc a C array of raw pointers
list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(list))))
// For the C ABI, malloc a C array of structs
list_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(list))))
defer C.free(unsafe.Pointer(list_CArray))
for i := range list {
list_i_ms := C.struct_miqt_string{}
Expand Down
8 changes: 4 additions & 4 deletions qt/gen_qcombobox.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,8 @@ func (this *QComboBox) AddItem2(icon *QIcon, text string) {
}

func (this *QComboBox) AddItems(texts []string) {
// For the C ABI, malloc a C array of raw pointers
texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(texts))))
// For the C ABI, malloc a C array of structs
texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts))))
defer C.free(unsafe.Pointer(texts_CArray))
for i := range texts {
texts_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -374,8 +374,8 @@ func (this *QComboBox) InsertItem2(index int, icon *QIcon, text string) {
}

func (this *QComboBox) InsertItems(index int, texts []string) {
// For the C ABI, malloc a C array of raw pointers
texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(texts))))
// For the C ABI, malloc a C array of structs
texts_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(texts))))
defer C.free(unsafe.Pointer(texts_CArray))
for i := range texts {
texts_i_ms := C.struct_miqt_string{}
Expand Down
20 changes: 10 additions & 10 deletions qt/gen_qcommandlineoption.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ func NewQCommandLineOption(name string) *QCommandLineOption {

// NewQCommandLineOption2 constructs a new QCommandLineOption object.
func NewQCommandLineOption2(names []string) *QCommandLineOption {
// For the C ABI, malloc a C array of raw pointers
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(names))))
// For the C ABI, malloc a C array of structs
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names))))
defer C.free(unsafe.Pointer(names_CArray))
for i := range names {
names_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -93,8 +93,8 @@ func NewQCommandLineOption3(name string, description string) *QCommandLineOption

// NewQCommandLineOption4 constructs a new QCommandLineOption object.
func NewQCommandLineOption4(names []string, description string) *QCommandLineOption {
// For the C ABI, malloc a C array of raw pointers
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(names))))
// For the C ABI, malloc a C array of structs
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names))))
defer C.free(unsafe.Pointer(names_CArray))
for i := range names {
names_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -161,8 +161,8 @@ func NewQCommandLineOption7(name string, description string, valueName string, d

// NewQCommandLineOption8 constructs a new QCommandLineOption object.
func NewQCommandLineOption8(names []string, description string, valueName string) *QCommandLineOption {
// For the C ABI, malloc a C array of raw pointers
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(names))))
// For the C ABI, malloc a C array of structs
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names))))
defer C.free(unsafe.Pointer(names_CArray))
for i := range names {
names_i_ms := C.struct_miqt_string{}
Expand All @@ -187,8 +187,8 @@ func NewQCommandLineOption8(names []string, description string, valueName string

// NewQCommandLineOption9 constructs a new QCommandLineOption object.
func NewQCommandLineOption9(names []string, description string, valueName string, defaultValue string) *QCommandLineOption {
// For the C ABI, malloc a C array of raw pointers
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(names))))
// For the C ABI, malloc a C array of structs
names_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(names))))
defer C.free(unsafe.Pointer(names_CArray))
for i := range names {
names_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -276,8 +276,8 @@ func (this *QCommandLineOption) SetDefaultValue(defaultValue string) {
}

func (this *QCommandLineOption) SetDefaultValues(defaultValues []string) {
// For the C ABI, malloc a C array of raw pointers
defaultValues_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(defaultValues))))
// For the C ABI, malloc a C array of structs
defaultValues_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(defaultValues))))
defer C.free(unsafe.Pointer(defaultValues_CArray))
for i := range defaultValues {
defaultValues_i_ms := C.struct_miqt_string{}
Expand Down
8 changes: 4 additions & 4 deletions qt/gen_qcommandlineparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ func (this *QCommandLineParser) ClearPositionalArguments() {
}

func (this *QCommandLineParser) Process(arguments []string) {
// For the C ABI, malloc a C array of raw pointers
arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(arguments))))
// For the C ABI, malloc a C array of structs
arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments))))
defer C.free(unsafe.Pointer(arguments_CArray))
for i := range arguments {
arguments_i_ms := C.struct_miqt_string{}
Expand All @@ -170,8 +170,8 @@ func (this *QCommandLineParser) ProcessWithApp(app *QCoreApplication) {
}

func (this *QCommandLineParser) Parse(arguments []string) bool {
// For the C ABI, malloc a C array of raw pointers
arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(arguments))))
// For the C ABI, malloc a C array of structs
arguments_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(arguments))))
defer C.free(unsafe.Pointer(arguments_CArray))
for i := range arguments {
arguments_i_ms := C.struct_miqt_string{}
Expand Down
8 changes: 4 additions & 4 deletions qt/gen_qcompleter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func NewQCompleter2(model *QAbstractItemModel) *QCompleter {

// NewQCompleter3 constructs a new QCompleter object.
func NewQCompleter3(completions []string) *QCompleter {
// For the C ABI, malloc a C array of raw pointers
completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(completions))))
// For the C ABI, malloc a C array of structs
completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions))))
defer C.free(unsafe.Pointer(completions_CArray))
for i := range completions {
completions_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -104,8 +104,8 @@ func NewQCompleter5(model *QAbstractItemModel, parent *QObject) *QCompleter {

// NewQCompleter6 constructs a new QCompleter object.
func NewQCompleter6(completions []string, parent *QObject) *QCompleter {
// For the C ABI, malloc a C array of raw pointers
completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(completions))))
// For the C ABI, malloc a C array of structs
completions_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(completions))))
defer C.free(unsafe.Pointer(completions_CArray))
for i := range completions {
completions_i_ms := C.struct_miqt_string{}
Expand Down
4 changes: 2 additions & 2 deletions qt/gen_qcoreapplication.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ func QCoreApplication_ApplicationPid() int64 {
}

func QCoreApplication_SetLibraryPaths(libraryPaths []string) {
// For the C ABI, malloc a C array of raw pointers
libraryPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(libraryPaths))))
// For the C ABI, malloc a C array of structs
libraryPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(libraryPaths))))
defer C.free(unsafe.Pointer(libraryPaths_CArray))
for i := range libraryPaths {
libraryPaths_i_ms := C.struct_miqt_string{}
Expand Down
36 changes: 18 additions & 18 deletions qt/gen_qdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ func QDir_SetSearchPaths(prefix string, searchPaths []string) {
prefix_ms.data = C.CString(prefix)
prefix_ms.len = C.size_t(len(prefix))
defer C.free(unsafe.Pointer(prefix_ms.data))
// For the C ABI, malloc a C array of raw pointers
searchPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(searchPaths))))
// For the C ABI, malloc a C array of structs
searchPaths_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(searchPaths))))
defer C.free(unsafe.Pointer(searchPaths_CArray))
for i := range searchPaths {
searchPaths_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -340,8 +340,8 @@ func (this *QDir) NameFilters() []string {
}

func (this *QDir) SetNameFilters(nameFilters []string) {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -419,8 +419,8 @@ func (this *QDir) EntryList() []string {
}

func (this *QDir) EntryListWithNameFilters(nameFilters []string) []string {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -459,8 +459,8 @@ func (this *QDir) EntryInfoList() []QFileInfo {
}

func (this *QDir) EntryInfoListWithNameFilters(nameFilters []string) []QFileInfo {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -689,8 +689,8 @@ func QDir_TempPath() string {
}

func QDir_Match(filters []string, fileName string) bool {
// For the C ABI, malloc a C array of raw pointers
filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(filters))))
// For the C ABI, malloc a C array of structs
filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters))))
defer C.free(unsafe.Pointer(filters_CArray))
for i := range filters {
filters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -768,8 +768,8 @@ func (this *QDir) EntryList2(filters QDir__Filter, sort QDir__SortFlag) []string
}

func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []string {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand All @@ -794,8 +794,8 @@ func (this *QDir) EntryList22(nameFilters []string, filters QDir__Filter) []stri
}

func (this *QDir) EntryList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []string {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -848,8 +848,8 @@ func (this *QDir) EntryInfoList2(filters QDir__Filter, sort QDir__SortFlag) []QF
}

func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) []QFileInfo {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand All @@ -874,8 +874,8 @@ func (this *QDir) EntryInfoList22(nameFilters []string, filters QDir__Filter) []
}

func (this *QDir) EntryInfoList3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) []QFileInfo {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down
12 changes: 6 additions & 6 deletions qt/gen_qdiriterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ func NewQDirIterator4(path string, nameFilters []string) *QDirIterator {
path_ms.data = C.CString(path)
path_ms.len = C.size_t(len(path))
defer C.free(unsafe.Pointer(path_ms.data))
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -130,8 +130,8 @@ func NewQDirIterator8(path string, nameFilters []string, filters QDir__Filter) *
path_ms.data = C.CString(path)
path_ms.len = C.size_t(len(path))
defer C.free(unsafe.Pointer(path_ms.data))
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand All @@ -152,8 +152,8 @@ func NewQDirIterator9(path string, nameFilters []string, filters QDir__Filter, f
path_ms.data = C.CString(path)
path_ms.len = C.size_t(len(path))
defer C.free(unsafe.Pointer(path_ms.data))
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down
12 changes: 6 additions & 6 deletions qt/gen_qdirmodel.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ func UnsafeNewQDirModel(h unsafe.Pointer) *QDirModel {

// NewQDirModel constructs a new QDirModel object.
func NewQDirModel(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag) *QDirModel {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand All @@ -77,8 +77,8 @@ func NewQDirModel2() *QDirModel {

// NewQDirModel3 constructs a new QDirModel object.
func NewQDirModel3(nameFilters []string, filters QDir__Filter, sort QDir__SortFlag, parent *QObject) *QDirModel {
// For the C ABI, malloc a C array of raw pointers
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(nameFilters))))
// For the C ABI, malloc a C array of structs
nameFilters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(nameFilters))))
defer C.free(unsafe.Pointer(nameFilters_CArray))
for i := range nameFilters {
nameFilters_i_ms := C.struct_miqt_string{}
Expand Down Expand Up @@ -222,8 +222,8 @@ func (this *QDirModel) IconProvider() *QFileIconProvider {
}

func (this *QDirModel) SetNameFilters(filters []string) {
// For the C ABI, malloc a C array of raw pointers
filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(8 * len(filters))))
// For the C ABI, malloc a C array of structs
filters_CArray := (*[0xffff]C.struct_miqt_string)(C.malloc(C.size_t(int(unsafe.Sizeof(C.struct_miqt_string{})) * len(filters))))
defer C.free(unsafe.Pointer(filters_CArray))
for i := range filters {
filters_i_ms := C.struct_miqt_string{}
Expand Down
Loading

0 comments on commit 7527c79

Please sign in to comment.