This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git

commit 498f097fdf264204b61dc72176682d99d1991239
Author: Szymon Janc <[email protected]>
AuthorDate: Thu Oct 15 18:03:50 2026 +0200

    newt/builder: Fix crash if project doesn't use apache-mynewt-core
    
    BasicEnvVars() dereferenced the apache-mynewt-core repo without checking
    if the project has it, causing a nil pointer dereference e.g. in "newt
    target config show". Set CORE_PATH only if the repo is present.
    
    Assisted-by: Claude:claude-opus-5-5
---
 newt/builder/buildutil.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/newt/builder/buildutil.go b/newt/builder/buildutil.go
index b99da740..5c9793eb 100644
--- a/newt/builder/buildutil.go
+++ b/newt/builder/buildutil.go
@@ -169,13 +169,17 @@ func BasicEnvVars(binBase string, bspPkg *pkg.BspPackage) 
map[string]string {
        newtPath, _ := osext.Executable()
 
        m := map[string]string{
-               "CORE_PATH":           coreRepo.Path(),
                "BSP_PATH":            bspPath,
                "BIN_ROOT":            BinRoot(),
                "MYNEWT_PROJECT_ROOT": ProjectRoot(),
                "MYNEWT_NEWT_PATH":    newtPath,
        }
 
+       // Project is not required to depend on apache-mynewt-core.
+       if coreRepo != nil {
+               m["CORE_PATH"] = coreRepo.Path()
+       }
+
        if binBase != "" {
                m["BIN_BASENAME"] = binBase
        }

Reply via email to