Skip to content

Commit a2b9054

Browse files
authored
Merge pull request #2 from Patch2PDF/nil-ptr-dereference
Nil ptr dereference
2 parents 543b87c + 323e333 commit a2b9054

4 files changed

Lines changed: 10 additions & 4 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25.4
44

55
require (
66
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2
7-
github.com/Patch2PDF/GDTF-Parser v0.2.1
7+
github.com/Patch2PDF/GDTF-Parser v0.2.2
88
golang.org/x/sync v0.19.0
99
)
1010

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2 h1:4LHeQjH+cwRoXuv+O4X9YoJaZAO/DihGGN5t3jVIFFk=
22
github.com/Patch2PDF/GDTF-Mesh-Reader v1.1.2/go.mod h1:4Uipj5UA1HhD3v032aSnEFlpItN80UY5zKB15mIeVwQ=
3-
github.com/Patch2PDF/GDTF-Parser v0.2.1 h1:FCyzL52Tx+wiS/NFLGbXgQSFSmc27evi8rOKfucBh5I=
4-
github.com/Patch2PDF/GDTF-Parser v0.2.1/go.mod h1:sXYpcmWKjVBL0JuRWyHwSFHRGzx6kex+HaS/vEPLZ2Y=
3+
github.com/Patch2PDF/GDTF-Parser v0.2.2 h1:MpUqTsRVxsgqfsM6oTFx1BPUgVL5TaAXfiomI2mMqYI=
4+
github.com/Patch2PDF/GDTF-Parser v0.2.2/go.mod h1:sXYpcmWKjVBL0JuRWyHwSFHRGzx6kex+HaS/vEPLZ2Y=
55
github.com/go-test/deep v1.0.1 h1:UQhStjbkDClarlmv0am7OXXO4/GaPdCGiUiMTvi28sg=
66
github.com/go-test/deep v1.0.1/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
77
github.com/qmuntal/gltf v0.28.0 h1:C4A1temWMPtcI2+qNfpfRq8FEJxoBGUN3ZZM8BCc+xU=

internal/types/mvrxml/general.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ type ConvertToDestinationMapStruct[T any] interface {
158158

159159
func ParseList[Source ConvertToDestinationStruct[Destination], Destination any](config ParseConfigData, source *[]Source) []Destination {
160160
if source == nil {
161-
return nil
161+
return []Destination{}
162162
}
163163
var destination []Destination = make([]Destination, len(*source))
164164
for index, element := range *source {
@@ -169,6 +169,9 @@ func ParseList[Source ConvertToDestinationStruct[Destination], Destination any](
169169
}
170170

171171
func ParseMap[Source ConvertToDestinationMapStruct[Destination], Destination any](config ParseConfigData, source *[]Source) map[string]*Destination {
172+
if source == nil {
173+
return map[string]*Destination{}
174+
}
172175
destination := make(map[string]*Destination)
173176
for _, element := range *source {
174177
parsedElement := element.Parse(config)

mvr-parser.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ func ParseMVRZipReader(zipfile *zip.Reader, config MVRTypes.MVRParserConfig) (*M
2727
}
2828

2929
// parse mvr xml
30+
if fileMap["GeneralSceneDescription.xml"] == nil {
31+
return nil, fmt.Errorf("Invalid MVR: missing GeneralSceneDescription.xml")
32+
}
3033
xmlFile, err := fileMap["GeneralSceneDescription.xml"].Open()
3134
if err != nil {
3235
return nil, err

0 commit comments

Comments
 (0)