You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/01/28 17:26:11 UTC
[mynewt-newt] 07/09: install: Don't dereference nil pointer
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newt.git
commit d1dcc192da7a6db6d8cf65a44994296c2f32f920
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Mon Jan 27 11:29:16 2020 -0800
install: Don't dereference nil pointer
The code was dereferencing `curVer` without checking if it was nil.
---
newt/install/install.go | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/newt/install/install.go b/newt/install/install.go
index 9085f28..5bc5f0c 100644
--- a/newt/install/install.go
+++ b/newt/install/install.go
@@ -344,21 +344,23 @@ func (inst *Installer) installPrompt(vm deprepo.VersionMap, op installOp,
for _, name := range names {
r := inst.repos[name]
curVer := inst.installedVer(name)
- if curVer != nil && curVer.Commit != "" {
- c, err := r.CurrentHash()
- if err == nil {
- curVer.Commit = c
+ if curVer != nil {
+ if curVer.Commit != "" {
+ c, err := r.CurrentHash()
+ if err == nil {
+ curVer.Commit = c
+ }
}
- }
- destVer := vm[name]
+ destVer := vm[name]
- msg, err := inst.installMessageOneRepo(
- r, op, force, curVer, destVer)
- if err != nil {
- return false, err
- }
+ msg, err := inst.installMessageOneRepo(
+ r, op, force, curVer, destVer)
+ if err != nil {
+ return false, err
+ }
- util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", msg)
+ util.StatusMessage(util.VERBOSITY_DEFAULT, "%s\n", msg)
+ }
}
if !ask {