diff options
Diffstat (limited to 'src/c_mpdview.c')
-rw-r--r-- | src/c_mpdview.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/c_mpdview.c b/src/c_mpdview.c index 26af420..46e11ed 100644 --- a/src/c_mpdview.c +++ b/src/c_mpdview.c @@ -39,13 +39,14 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * mpdview: src/c_mpdview.c - * Sun, 03 Jul 2022 16:06:29 +0200 + * Tue, 12 Jul 2022 21:36:26 +0200 * Joe * * This is the entrypoint of the program. */ #include <sys/param.h> +#include <sys/syslimits.h> #include <stdlib.h> #include <stdio.h> @@ -70,6 +71,9 @@ c_create_view(void) struct mpdview_s* view; view = (struct mpdview_s*)malloc(sizeof(struct mpdview_s)); + if (view == NULL) { + return (NULL); + } view->conn = NULL; view->status = NULL; view->song = NULL; @@ -159,17 +163,12 @@ c_get_current_dir(struct mpdview_s* v) { ptr_t ptr; - snprintf( - v->current_dir, - PATH_MAX, - "%s/%s", - v->music_dir, - mpd_song_get_uri(v->song) - ); + strlcpy(v->current_dir, v->music_dir, PATH_MAX); + v->current_dir[strlen(v->current_dir) + 1] = 0x00; + v->current_dir[strlen(v->current_dir)] = '/'; + strlcat(v->current_dir, mpd_song_get_uri(v->song), PATH_MAX); ptr = v->current_dir; - while (*ptr != 0x00) { - ptr++; - } + ptr += strlen(v->current_dir); while (*ptr != '/' && ptr > v->music_dir) { ptr--; } |