diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-10 13:51:41 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2014-08-10 15:50:08 +0200 |
commit | 733eb99b1773452f11318d856ed4f1008f1bf8fa (patch) | |
tree | 028c3cc89ccd34676458cdeac04d4a2c365c2c20 /src/plugins/script/script-repo.c | |
parent | a7ea40da2c4693a32ddfa9127d645a52ae6f9c46 (diff) | |
download | weechat-733eb99b1773452f11318d856ed4f1008f1bf8fa.zip |
script: fix potential crash in case of malloc error
Diffstat (limited to 'src/plugins/script/script-repo.c')
-rw-r--r-- | src/plugins/script/script-repo.c | 20 |
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'; } } |