mirror of
https://github.com/Ponce/slackbuilds
synced 2024-11-29 13:00:32 +01:00
d3a4af2a13
Signed-off-by: Dave Woodfall <dave@slackbuilds.org> Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
34 lines
943 B
Diff
34 lines
943 B
Diff
Author: Jonathan Niehof <jtniehof@gmail.com>
|
|
Subject: Fix segfault if $HOME not set and -config passed
|
|
Bug-Debian: https://bugs.debian.org/716582
|
|
Forwarded: https://sourceforge.net/p/joy2key/patches/5/
|
|
Last-Update: 2013-07-13
|
|
|
|
--- a/joy2key.c
|
|
+++ b/joy2key.c
|
|
@@ -386,6 +386,7 @@
|
|
FILE *file;
|
|
int rcargc;
|
|
char *rcargv[255], line[255];
|
|
+ char *homedir;
|
|
|
|
for(i=1; i<argc; i++)
|
|
{
|
|
@@ -442,9 +443,15 @@
|
|
}
|
|
if(strcmp(rcfile,DEFAULT_RCFILE) == 0)
|
|
{
|
|
- x=strlen(getenv("HOME")) + strlen(rcfile) + 2;
|
|
+ homedir=getenv("HOME");
|
|
+ if(homedir==NULL)
|
|
+ {
|
|
+ printf("No home directory; cannot open default rc file\n");
|
|
+ exit(1);
|
|
+ }
|
|
+ x=strlen(homedir) + strlen(rcfile) + 2;
|
|
rcfile=(char*)malloc(x);
|
|
- sprintf(rcfile, "%s/%s", getenv("HOME"), DEFAULT_RCFILE);
|
|
+ sprintf(rcfile, "%s/%s", homedir, DEFAULT_RCFILE);
|
|
}
|
|
if((file=fopen(rcfile, "r"))==NULL)
|
|
{
|