Skip to content

Commit

Permalink
use parse int to prevent unexpected behaviours
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Nov 27, 2024
1 parent 942438d commit 19f7c1b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/internal/server/company_financials.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *Server) handleGetCompanyFinancials(c echo.Context) error {

year := c.QueryParam("year")
if year != "" {
yearInt, err := strconv.Atoi(year)
yearInt, err := strconv.ParseInt(year, 10, 32)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid year format")
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func (s *Server) handleUpdateCompanyFinancials(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Year parameter is required")
}

yearInt, err := strconv.Atoi(year)
yearInt, err := strconv.ParseInt(year, 10, 32)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid year format")
}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (s *Server) handleDeleteCompanyFinancials(c echo.Context) error {
return echo.NewHTTPError(http.StatusBadRequest, "Year parameter is required")
}

yearInt, err := strconv.Atoi(year)
yearInt, err := strconv.ParseInt(year, 10, 32)
if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "Invalid year format")
}
Expand Down

0 comments on commit 19f7c1b

Please sign in to comment.