Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: avoid nil pointer dereference #2061

Merged
merged 2 commits into from
Aug 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions api/internal/handler/data_loader/route_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down