[fix] null pointer deref
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Evan Reichard 2023-11-05 21:20:15 -05:00
parent c213b3b09f
commit 3cbe4b1c0d

View File

@ -55,15 +55,30 @@ func (api *API) opdsDocuments(c *gin.Context) {
splitFilepath := strings.Split(*doc.Filepath, ".") splitFilepath := strings.Split(*doc.Filepath, ".")
fileType := splitFilepath[len(splitFilepath)-1] 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{ 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{ Author: []opds.Author{
{ {
Name: *doc.Author, Name: author,
}, },
}, },
Content: &opds.Content{ Content: &opds.Content{
Content: *doc.Description, Content: description,
ContentType: "text", ContentType: "text",
}, },
Links: []opds.Link{ Links: []opds.Link{