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 755bc162e450addba4d66f8192988c7db932b646 Author: Szymon Janc <[email protected]> AuthorDate: Thu Oct 22 16:20:50 2026 +0200 newt/builder: Close map file on all return paths parseMapFileRegions() never closed the map file and ParseMapFileSizes() leaked it on parse errors. On Windows an open file cannot be removed, which made the map file parser tests fail when cleaning up their temporary directories. Assisted-by: Claude:claude-opus-5-5 --- newt/builder/size.go | 2 +- newt/builder/size_report.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/newt/builder/size.go b/newt/builder/size.go index 60b21c51..5fba6eb3 100644 --- a/newt/builder/size.go +++ b/newt/builder/size.go @@ -172,6 +172,7 @@ func ParseMapFileSizes(fileName string) (map[string]*PkgSize, error) { if err != nil { return nil, util.NewNewtError("Mapfile failed: " + err.Error()) } + defer file.Close() var symName string = "" @@ -351,7 +352,6 @@ func ParseMapFileSizes(fileName string) (map[string]*PkgSize, error) { default: } } - file.Close() for name, section := range globalMemSections { util.StatusMessage(util.VERBOSITY_VERBOSE, "Mem %s: 0x%x-0x%x\n", name, section.Offset, section.EndOff) diff --git a/newt/builder/size_report.go b/newt/builder/size_report.go index d0cc801e..76ad6057 100644 --- a/newt/builder/size_report.go +++ b/newt/builder/size_report.go @@ -249,6 +249,7 @@ func parseMapFileRegions(fileName string, sectionName string) (*MemoryRegion, if err != nil { return nil, err } + defer file.Close() sectionRegion := MakeMemoryRegion()
