Skip to content

Commit

Permalink
fix potential leak and return 409 on repeated slug
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloose committed Nov 28, 2024
1 parent 64dfd8e commit c681fd6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stiller-backend/internal/handlers/post_gallery.new.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ func PostGalleryNew(w http.ResponseWriter, r *http.Request, params httprouter.Pa
newgallery_query, newgallery_args := newgallery_stmt.String(), newgallery_stmt.Args()

dbconn, dbconn_err := dbutils.NewConn()
if loggers.RequestLog(dbconn_err, "", http.StatusConflict, &w) {
defer dbutils.CloseConn(dbconn)

if loggers.RequestLog(dbconn_err, "", http.StatusInternalServerError, &w) {
return
}

defer dbutils.CloseConn(dbconn)

newgallery_id := int(-1)
exec_err := sqlitex.ExecuteTransient(dbconn, newgallery_query, &sqlitex.ExecOptions{
ResultFunc: func(stmt *sqlite.Stmt) error {
Expand All @@ -74,7 +74,7 @@ func PostGalleryNew(w http.ResponseWriter, r *http.Request, params httprouter.Pa
Args: newgallery_args,
})

if loggers.RequestLog(exec_err, "", http.StatusBadRequest, &w) {
if loggers.RequestLog(exec_err, "", http.StatusConflict, &w) {
return
}

Expand Down

0 comments on commit c681fd6

Please sign in to comment.