Skip to content

fix(v2/hcore): prevent panic in StartService when HiddifyOptions is nil#125

Open
nisemenov wants to merge 1 commit intohiddify:mainfrom
nisemenov:fix/nil-pointer-build-config
Open

fix(v2/hcore): prevent panic in StartService when HiddifyOptions is nil#125
nisemenov wants to merge 1 commit intohiddify:mainfrom
nisemenov:fix/nil-pointer-build-config

Conversation

@nisemenov
Copy link
Copy Markdown

Problem

StartService may panic when static.HiddifyOptions is nil.

startmobile panic: runtime error:
invalid memory address or nil pointer dereference goroutine 15 [running]: runtime/debug.Stack()
runtime/debug/stack.go:26 +0x64
github.com/hiddify/hiddify-core/v2/
config. DeferPanicToError ({0x105bb e11f, Oxb}, 0x13006b818)
github.com/hiddify/hiddify-core/v2/
config/debug.go:30 +0x44
panic ({0x106181620?, 0x107609ba0?})
runtime/panic.go:783 +0x120
github.com/hiddify/hiddify-core/v2/
config. BuildConfig ({0x10656e3c8?,
0x13022c090?}, Оx0, 0x1?)
github.com/hiddify/hiddify-core/v2/
config/builder.go:70 +0x50
github.com/hiddify/hiddify-core/v2/
hcore.BuildConfig({0x10656e3c8,
0x13022c090}, 0x1302867e0)
github.com/hiddify/hiddify-core/v2/
hcore/buildconfighelper.go:40

This can occur in some environments where StartService is invoked
before internal state is fully initialized (e.g. app lifecycle edge cases).

Solution

  • Add a guard in StartService to check for nil HiddifyOptions
  • Return a proper error instead of allowing a panic

Notes

This makes the startup logic more robust against invalid state without changing deeper configuration logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant