iand / gedcom

Go package to parse GEDCOM files.
The Unlicense
37 stars 10 forks source link

Parser crashed on access to GEDCOM header fields #5

Closed ligurio closed 2 years ago

ligurio commented 7 years ago

Example of Golang code:

package main

import (
        "bytes"
        "fmt"
        "github.com/iand/gedcom"
        "io/ioutil"
)

func main() {

        data, _ := ioutil.ReadFile("info.ged")
        d := gedcom.NewDecoder(bytes.NewReader(data))
        g, _ := d.Decode()

        fmt.Printf("#%v", g.Header.SourceSystem)
}

Sample of GEDCOM file:

0 HEAD
1 SOUR LIFELINES 3.0.62
1 DEST ANY
1 DATE 26 JUL 2017
2 TIME 23:26
1 SUBM
1 GEDC
2 VERS 5.5
2 FORM LINEAGE-LINKED
1 CHAR UTF-8
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x2177]

goroutine 1 [running]:
panic(0xb43e0, 0xc42000a1b0)
        /usr/local/Cellar/go/1.7.4_2/libexec/src/runtime/panic.go:500 +0x1a1
main.main()
        /Users/sergeyb/source/gopath/src/github.com/ligurio/gedcom2sql/repro.go:16 +0x137
djhenderson commented 7 years ago

On 26 July 2017 at 14:55, Sergey Bronnikov wrote:

Sample of GEDCOM file:

0 HEAD 1 SOUR LIFELINES 3.0.62 1 DEST ANY 1 DATE 26 JUL 2017 2 TIME 23:26 1 SUBM 1 GEDC 2 VERS 5.5 2 FORM LINEAGE-LINKED 1 CHAR UTF-8

I tested this and your other failing sample using my fork of this repository. Both ran successfully in my test bed. I have added major changes, mostly related to handling allged.ged and every gedcom file I could find on my laptop. I don't recall changing the api, so you should be able to try it out easily.

go get github.com/djhenderson/gedcom

HTH Doug

-- Doug Henderson, Calgary, Alberta, Canada - from gmail.com

iand commented 7 years ago

This sound great @djhenderson. Are you interested in folding your changes back into my original and becoming a maintainer?

iand commented 7 years ago

Note I am away on vacation from tonight so I won't be able to respond until the week after next

djhenderson commented 7 years ago

I hesitate as my updated SLOC may be greater than your original SLOC. I have made a lot of changes. Also, the tests have lagged behind, so that only some of them are working now. I also would like to add some benchmarks. Looking back, my commits were not well organized for collaboration. You are welcome to browse my fork to see what I have done.

iand commented 2 years ago

Don't believe this is an issue any more. Please file a new issue if you encounter it again.