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

liuxiran pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new a3ac120  fix: avoid nil pointer dereference (#2061)
a3ac120 is described below

commit a3ac1204eadf3e8d891f4e9670c725f589e781d4
Author: okaybase <75366457+okayb...@users.noreply.github.com>
AuthorDate: Mon Aug 23 08:23:51 2021 +0800

    fix: avoid nil pointer dereference (#2061)
---
 api/internal/handler/data_loader/route_export.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/api/internal/handler/data_loader/route_export.go 
b/api/internal/handler/data_loader/route_export.go
index aa8218c..dd0c3c5 100644
--- a/api/internal/handler/data_loader/route_export.go
+++ b/api/internal/handler/data_loader/route_export.go
@@ -115,14 +115,14 @@ var (
 func (h *Handler) ExportAllRoutes(c droplet.Context) (interface{}, error) {
        routelist, err := h.routeStore.List(c.Context(), store.ListInput{})
 
-       if len(routelist.Rows) < 1 {
-               return nil, consts.ErrRouteData
-       }
-
        if err != nil {
                return nil, err
        }
 
+       if len(routelist.Rows) < 1 {
+               return nil, consts.ErrRouteData
+       }
+
        routes := []*entity.Route{}
 
        for _, route := range routelist.Rows {
@@ -412,7 +412,7 @@ func ParseRoutePlugins(route *entity.Route, paramsRefs 
[]*openapi3.ParameterRef,
                                log.Errorf("Plugins MergeJson err: ", err)
                                return path, nil, nil, nil, err
                        }
-                       err = json.Unmarshal([]byte(bytePlugins), &plugins)
+                       err = json.Unmarshal(bytePlugins, &plugins)
                        if err != nil {
                                log.Errorf("JsonToMapDemo err: ", err)
                                return path, nil, nil, nil, err

Reply via email to