Coder Social home page Coder Social logo

reggie's People

Stargazers

Daniel avatar Matheus da Silva Garcias avatar

Watchers

Node avatar

reggie's Issues

Nil pointer dereference when using the Traverse() function

When using the Traverse() function with only it's implicit behaviour (currently in dev branch only), eventually the traversal will raise a runtime error and panic.

Reproducible with the following code:

func main() {
	r := reggie.New()
	r.RootKey = registry.CURRENT_USER
	r.Path = `SOFTWARE`
	r.Permission = registry.ALL_ACCESS
	err := r.GetKeysValues()
	if err != nil {
		fmt.Println(err)
		return
	}
	err = reggie.Traverse(r, func(reg *reggie.Reg) {
		if reg != nil {
			fmt.Printf("\nPath: %s", reg.Path)
		}
	})
	if err != nil {
		fmt.Println(err)
	}
}

What seems to happen is the SubKey struct becomes <nil>. This was identified through some basic print debugging:

func (s *SubKey) OpenKey(populateKeyValues bool) (*Reg, error) {
	fmt.Println("OPENING KEY", s)
	k := Reg{
		RootKey:    s.Key.RootKey,
		Path:       s.Key.Path,
		Permission: s.Key.Permission,
		SubKeys:    make(map[string]*SubKey),
	}
...

The error that generates

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x56035e]

Output given just before error (giving last two keys opened)

Path: SOFTWARE\ej-technologies\exe4j
DEBUG:  &{0xc0001538c0 map[]} 2147483649 &{2147483649 SOFTWARE\ej-technologies\exe4j\jvms 983103 848 map[]} map[] map[] SOFTWARE\ej-technologies\exe4j\jvms 0
OPENING KEY &{0xc0001538c0 map[]}
{2147483649 SOFTWARE\ej-technologies\exe4j\jvms 983103 0 map[]}
{2147483649 SOFTWARE\ej-technologies\exe4j\jvms 983103 0 map[c:/program files/runemate/jre/bin/java.exe:0xc000168bc0]}

Path: SOFTWARE\ej-technologies\exe4j\jvms
DEBUG:  &{0xc000153c20 map[LastWriteTime:[208 96 190 223 149 172 216 1] Version:11.0.14]} 2147483649 &{2147483649 SOFTWARE\ej-technologies\exe4j\jvms\c:/program files/runemate/jre/bin/java.exe 983103 860 map[]} map[LastWriteTime:[
208 96 190 223 149 172 216 1] Version:11.0.14] map[] SOFTWARE\ej-technologies\exe4j\jvms\c:/program files/runemate/jre/bin/java.exe 0
OPENING KEY <nil>

You can see that the opening key has a pointer during traversal of multiple registry keys, but eventually turns <nil> when working its way down.

The reason why is unknown but this is something that urgently needs a stable fix.

Sigh, what a problematic error.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.