From d866a36eadddc6b4f2d0c8a9c215548b90c5b54c Mon Sep 17 00:00:00 2001 From: newb1er Date: Thu, 25 Apr 2024 13:49:34 +0800 Subject: [PATCH] fix: nil dereference --- .../sbi/nssaiavailability/nssaiavailability_store.go | 10 +++++----- .../nssaiavailability_subscription.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/sbi/nssaiavailability/nssaiavailability_store.go b/internal/sbi/nssaiavailability/nssaiavailability_store.go index 609c1a0..0aeccbe 100644 --- a/internal/sbi/nssaiavailability/nssaiavailability_store.go +++ b/internal/sbi/nssaiavailability/nssaiavailability_store.go @@ -33,7 +33,7 @@ func NfInstanceDelete(nfId string) *models.ProblemDetails { } } - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId), @@ -81,7 +81,7 @@ func NfInstancePatch(nssaiAvailabilityUpdateInfo plugin.PatchDocument, nfId stri } factory.NssfConfig.RUnlock() if !hitAmf { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("AMF ID '%s' does not exist", nfId), @@ -108,7 +108,7 @@ func NfInstancePatch(nssaiAvailabilityUpdateInfo plugin.PatchDocument, nfId stri patch, err := jsonpatch.DecodePatch(patchJSON) if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.MALFORMED_REQUEST, Status: http.StatusBadRequest, Detail: err.Error(), @@ -118,7 +118,7 @@ func NfInstancePatch(nssaiAvailabilityUpdateInfo plugin.PatchDocument, nfId stri modified, err := patch.Apply(original) if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.INVALID_REQUEST, Status: http.StatusConflict, Detail: err.Error(), @@ -130,7 +130,7 @@ func NfInstancePatch(nssaiAvailabilityUpdateInfo plugin.PatchDocument, nfId stri err = json.Unmarshal(modified, &factory.NssfConfig.Configuration.AmfList[amfIdx].SupportedNssaiAvailabilityData) factory.NssfConfig.Unlock() if err != nil { - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.INVALID_REQUEST, Status: http.StatusBadRequest, Detail: err.Error(), diff --git a/internal/sbi/nssaiavailability/nssaiavailability_subscription.go b/internal/sbi/nssaiavailability/nssaiavailability_subscription.go index 0d37329..cc08f57 100644 --- a/internal/sbi/nssaiavailability/nssaiavailability_subscription.go +++ b/internal/sbi/nssaiavailability/nssaiavailability_subscription.go @@ -56,7 +56,7 @@ func SubscriptionCreate(createData models.NssfEventSubscriptionCreateData) ( if err != nil { logger.NssaiavailLog.Warnf(err.Error()) - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: err.Error(), @@ -95,7 +95,7 @@ func SubscriptionUnsubscribe(subscriptionId string) *models.ProblemDetails { } // No specific subscription ID exists - *problemDetails = models.ProblemDetails{ + problemDetails = &models.ProblemDetails{ Title: util.UNSUPPORTED_RESOURCE, Status: http.StatusNotFound, Detail: fmt.Sprintf("Subscription ID '%s' is not available", subscriptionId),