Created
May 15, 2018 03:39
-
-
Save PuercoPop/bb55db32b0deeb00a3023f7c5deb744a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
index 124e380..1e8b8f8 100644 | |
--- a/vis-lua.c | |
+++ b/vis-lua.c | |
@@ -2643,7 +2643,8 @@ void vis_lua_init(Vis *vis) { | |
* - /usr/(local/)?share/vis (or whatever is specified during ./configure) | |
* - package.path (standard lua search path) | |
*/ | |
- char path[PATH_MAX]; | |
+ char *path; | |
+ size_t path_len; | |
vis_lua_path_add(vis, VIS_PATH); | |
@@ -2659,10 +2660,14 @@ void vis_lua_init(Vis *vis) { | |
const char *xdg_config = getenv("XDG_CONFIG_HOME"); | |
if (xdg_config) { | |
- snprintf(path, sizeof path, "%s/vis", xdg_config); | |
+ path_len = snprintf(NULL, 0, "%s/vis", xdg_config); | |
+ path = malloc(path_len + 1); | |
+ snprintf(path, path_len + 1, "%s/vis", xdg_config); | |
vis_lua_path_add(vis, path); | |
} else if (home && *home) { | |
- snprintf(path, sizeof path, "%s/.config/vis", home); | |
+ path_len = snprintf(NULL, 0, "%s/.config/vis", home); | |
+ path = malloc(path_len + 1); | |
+ snprintf(path, path_len + 1, "%s/.config/vis", home); | |
vis_lua_path_add(vis, path); | |
} | |
~ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment