xsel

Program for manipulating the X clipboard
git clone https://git.sinitax.com/kfish/xsel
Log | Files | Refs | README | LICENSE | sfeed.txt

commit ee7b48111be2e2117b201962e9d1c0e1f9804ed4
parent 30fd5dbf1b0f6f7f915ce0f1b6db69bdb9180fb8
Author: Conrad Parker <conrad@metadecks.org>
Date:   Thu, 24 Aug 2017 09:55:46 +0800

Merge pull request #21 from e7appew/fix-get_xdg_cache_home

Do not modify HOME environment variable.
Diffstat:
Mxsel.c | 15+++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/xsel.c b/xsel.c @@ -343,12 +343,21 @@ static char * get_xdg_cache_home (void) { char * cachedir; + char * homedir; + static const char * slashbasename = "/.cache"; if ((cachedir = getenv ("XDG_CACHE_HOME")) == NULL) { - cachedir = strcat(getenv ("HOME"), "/.cache"); + if ((homedir = getenv ("HOME")) == NULL) { + exit_err ("no HOME directory"); + } + cachedir = xs_malloc (strlen (homedir) + strlen (slashbasename) + 1); + strcpy (cachedir, homedir); + strcat (cachedir, slashbasename); + } else { + cachedir = _xs_strdup (cachedir); } - mkdir(cachedir, S_IRWXU|S_IRGRP|S_IXGRP); + mkdir (cachedir, S_IRWXU|S_IRGRP|S_IXGRP); return cachedir; } @@ -515,6 +524,8 @@ become_daemon (void) } set_daemon_timeout (); + + free (cachedir); } /*