From 1be84c6c3b8049a4d8d48ec3965c66c60fd0a349 Mon Sep 17 00:00:00 2001 From: Sidharth Kapur Date: Mon, 5 Oct 2015 10:21:54 -0500 Subject: [PATCH] Use glib malloc instead of malloc --- zathura/zathura.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zathura/zathura.c b/zathura/zathura.c index a43b11f..c2c8b7b 100644 --- a/zathura/zathura.c +++ b/zathura/zathura.c @@ -556,13 +556,13 @@ get_window_title_filename(zathura_t* zathura, const char* file_path) girara_setting_get(zathura->ui.session, "window-title-home-tilde", &home_tilde); if (home_tilde) { char *home = getenv("HOME"); - int home_len = home ? strlen(home) : 0; - int file_path_len = file_path ? strlen(file_path) : 0; + size_t home_len = home ? strlen(home) : 0; + size_t file_path_len = file_path ? strlen(file_path) : 0; if (home_len > 1 && strncmp(home, file_path, home_len) == 0 && (!file_path[home_len] || file_path[home_len] == '/')) { // Length should be total length of path - length of $HOME + 1 for '~' + 1 for '\0' int tlen = file_path_len - home_len + 2; - char *tdir = malloc(sizeof(char) * tlen); + char *tdir = g_try_malloc(sizeof(char) * tlen); strncpy(tdir + 1, file_path + home_len, tlen); tdir[0] = '~'; tdir[tlen - 1] = '\0';