summaryrefslogtreecommitdiff
path: root/src/plugins/script
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-08-10 13:51:41 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-08-10 15:50:08 +0200
commit733eb99b1773452f11318d856ed4f1008f1bf8fa (patch)
tree028c3cc89ccd34676458cdeac04d4a2c365c2c20 /src/plugins/script
parenta7ea40da2c4693a32ddfa9127d645a52ae6f9c46 (diff)
downloadweechat-733eb99b1773452f11318d856ed4f1008f1bf8fa.zip
script: fix potential crash in case of malloc error
Diffstat (limited to 'src/plugins/script')
-rw-r--r--src/plugins/script/script-repo.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/plugins/script/script-repo.c b/src/plugins/script/script-repo.c
index a3e6d7cd7..bd6d5105b 100644
--- a/src/plugins/script/script-repo.c
+++ b/src/plugins/script/script-repo.c
@@ -174,22 +174,22 @@ script_repo_get_filename_loaded (struct t_script_repo *script)
weechat_home = weechat_info_get ("weechat_dir", NULL);
length = strlen (weechat_home) + strlen (script->name_with_extension) + 64;
filename = malloc (length);
- if (filename)
+ if (!filename)
+ return NULL;
+
+ snprintf (filename, length, "%s/%s/autoload/%s",
+ weechat_home,
+ script_language[script->language],
+ script->name_with_extension);
+ if (stat (filename, &st) != 0)
{
- snprintf (filename, length, "%s/%s/autoload/%s",
+ snprintf (filename, length, "%s/%s/%s",
weechat_home,
script_language[script->language],
script->name_with_extension);
if (stat (filename, &st) != 0)
{
- snprintf (filename, length, "%s/%s/%s",
- weechat_home,
- script_language[script->language],
- script->name_with_extension);
- if (stat (filename, &st) != 0)
- {
- filename[0] = '\0';
- }
+ filename[0] = '\0';
}
}