mirror of
https://github.com/owntone/owntone-server.git
synced 2025-01-15 08:45:02 -05:00
Fixes issues found by scan-build in mpd.c and queue.c
This commit is contained in:
parent
94a55d9fc9
commit
a95da7966b
50
src/mpd.c
50
src/mpd.c
@ -437,18 +437,20 @@ mpd_add_mediainfo(struct evbuffer *evbuf, struct media_file_info *mfi, unsigned
|
|||||||
mfi->genre,
|
mfi->genre,
|
||||||
mfi->disc);
|
mfi->disc);
|
||||||
|
|
||||||
if (pos_pl >= 0)
|
if (ret >= 0 && pos_pl >= 0)
|
||||||
{
|
{
|
||||||
ret = evbuffer_add_printf(evbuf,
|
ret = evbuffer_add_printf(evbuf,
|
||||||
"Pos: %d\n",
|
"Pos: %d\n",
|
||||||
pos_pl);
|
pos_pl);
|
||||||
|
|
||||||
ret = evbuffer_add_printf(evbuf,
|
if (ret >= 0)
|
||||||
"Id: %d\n",
|
{
|
||||||
item_id);
|
ret = evbuffer_add_printf(evbuf,
|
||||||
|
"Id: %d\n",
|
||||||
|
item_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2039,12 +2041,16 @@ mpd_command_listplaylist(struct evbuffer *evbuf, int argc, char **argv, char **e
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(argv[1], "/", 1) == 0)
|
if (strncmp(argv[1], "/", 1) == 0)
|
||||||
{
|
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
||||||
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
||||||
|
|
||||||
|
if (ret >= sizeof(path))
|
||||||
{
|
{
|
||||||
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
ret = asprintf(errmsg, "Length of path exceeds the PATH_MAX value '%s'", argv[1]);
|
||||||
|
if (ret < 0)
|
||||||
|
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
|
||||||
|
return ACK_ERROR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
pli = db_pl_fetch_byvirtualpath(path);
|
pli = db_pl_fetch_byvirtualpath(path);
|
||||||
@ -2111,12 +2117,16 @@ mpd_command_listplaylistinfo(struct evbuffer *evbuf, int argc, char **argv, char
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(argv[1], "/", 1) == 0)
|
if (strncmp(argv[1], "/", 1) == 0)
|
||||||
{
|
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
||||||
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
||||||
|
|
||||||
|
if (ret >= sizeof(path))
|
||||||
{
|
{
|
||||||
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
ret = asprintf(errmsg, "Length of path exceeds the PATH_MAX value '%s'", argv[1]);
|
||||||
|
if (ret < 0)
|
||||||
|
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
|
||||||
|
return ACK_ERROR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
pli = db_pl_fetch_byvirtualpath(path);
|
pli = db_pl_fetch_byvirtualpath(path);
|
||||||
@ -2241,12 +2251,16 @@ mpd_command_load(struct evbuffer *evbuf, int argc, char **argv, char **errmsg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strncmp(argv[1], "/", 1) == 0)
|
if (strncmp(argv[1], "/", 1) == 0)
|
||||||
{
|
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
||||||
ret = snprintf(path, sizeof(path), "%s", argv[1]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
||||||
|
|
||||||
|
if (ret >= sizeof(path))
|
||||||
{
|
{
|
||||||
ret = snprintf(path, sizeof(path), "/%s", argv[1]);
|
ret = asprintf(errmsg, "Length of path exceeds the PATH_MAX value '%s'", argv[1]);
|
||||||
|
if (ret < 0)
|
||||||
|
DPRINTF(E_LOG, L_MPD, "Out of memory\n");
|
||||||
|
return ACK_ERROR_ARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
pli = db_pl_fetch_byvirtualpath(path);
|
pli = db_pl_fetch_byvirtualpath(path);
|
||||||
@ -4276,7 +4290,7 @@ mpd_read_cb(struct bufferevent *bev, void *ctx)
|
|||||||
|
|
||||||
// Split the read line into command name and arguments
|
// Split the read line into command name and arguments
|
||||||
ret = mpd_parse_args(line, &argc, argv);
|
ret = mpd_parse_args(line, &argc, argv);
|
||||||
if (ret != 0)
|
if (ret != 0 || argc <= 0)
|
||||||
{
|
{
|
||||||
// Error handling for argument parsing error
|
// Error handling for argument parsing error
|
||||||
DPRINTF(E_LOG, L_MPD, "Error parsing arguments for MPD message: %s\n", line);
|
DPRINTF(E_LOG, L_MPD, "Error parsing arguments for MPD message: %s\n", line);
|
||||||
|
10
src/queue.c
10
src/queue.c
@ -117,7 +117,7 @@ queue_new()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Frees the given item and all linked items
|
* Frees the given item and all linked (next) items
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
queue_items_free(struct queue_item *item)
|
queue_items_free(struct queue_item *item)
|
||||||
@ -125,7 +125,12 @@ queue_items_free(struct queue_item *item)
|
|||||||
struct queue_item *temp;
|
struct queue_item *temp;
|
||||||
struct queue_item *next;
|
struct queue_item *next;
|
||||||
|
|
||||||
item->prev->next = NULL;
|
if (!item)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Make the queue non-circular
|
||||||
|
if (item->prev)
|
||||||
|
item->prev->next = NULL;
|
||||||
|
|
||||||
next = item;
|
next = item;
|
||||||
while (next)
|
while (next)
|
||||||
@ -1194,6 +1199,7 @@ queueitem_make_byquery(struct query_params *qp)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
DPRINTF(E_LOG, L_PLAYER, "Error fetching results\n");
|
DPRINTF(E_LOG, L_PLAYER, "Error fetching results\n");
|
||||||
|
queue_items_free(item_tail);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user