From 3cbe4b1c0da9da0e44096565244c0a03b35e36c3 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Sun, 5 Nov 2023 21:20:15 -0500 Subject: [PATCH] [fix] null pointer deref --- api/opds-routes.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/api/opds-routes.go b/api/opds-routes.go index a783688..87c65f2 100644 --- a/api/opds-routes.go +++ b/api/opds-routes.go @@ -55,15 +55,30 @@ func (api *API) opdsDocuments(c *gin.Context) { splitFilepath := strings.Split(*doc.Filepath, ".") fileType := splitFilepath[len(splitFilepath)-1] + title := "N/A" + if doc.Title != nil { + title = *doc.Title + } + + author := "N/A" + if doc.Author != nil { + author = *doc.Author + } + + description := "N/A" + if doc.Description != nil { + description = *doc.Description + } + item := opds.Entry{ - Title: fmt.Sprintf("[%3d%%] %s", int(doc.Percentage), *doc.Title), + Title: fmt.Sprintf("[%3d%%] %s", int(doc.Percentage), title), Author: []opds.Author{ { - Name: *doc.Author, + Name: author, }, }, Content: &opds.Content{ - Content: *doc.Description, + Content: description, ContentType: "text", }, Links: []opds.Link{