summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2006-10-20 09:19:51 +0000
committerSebastien Helleu <flashcode@flashtux.org>2006-10-20 09:19:51 +0000
commita3878a522c98dd8d1060ce20f279419aad83aa25 (patch)
treec06eed7ba9ef7300bccca06d69b24ca955bb1da6 /src
parent06c4cf414435f14f463732886e06ccfa699fc815 (diff)
downloadweechat-a3878a522c98dd8d1060ce20f279419aad83aa25.zip
Fixed crash when loading ruby script if file does not exist, with Ruby >= 1.9 only (bug #18064)
Diffstat (limited to 'src')
-rw-r--r--src/plugins/scripts/lua/weechat-lua.c5
-rw-r--r--src/plugins/scripts/perl/weechat-perl.c15
-rw-r--r--src/plugins/scripts/python/weechat-python.c7
-rw-r--r--src/plugins/scripts/ruby/weechat-ruby.c13
4 files changed, 30 insertions, 10 deletions
diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c
index 2008f649c..950baf90e 100644
--- a/src/plugins/scripts/lua/weechat-lua.c
+++ b/src/plugins/scripts/lua/weechat-lua.c
@@ -1936,12 +1936,11 @@ weechat_lua_load (t_weechat_plugin *plugin, char *filename)
if ((fp = fopen (filename, "r")) == NULL)
{
- plugin->print_server (plugin,
- "Lua error: unable to open file \"%s\"",
+ plugin->print_server (plugin, "Lua error: script \"%s\" not found",
filename);
return 0;
}
-
+
lua_current_script = NULL;
lua_current_interpreter = lua_open ();
diff --git a/src/plugins/scripts/perl/weechat-perl.c b/src/plugins/scripts/perl/weechat-perl.c
index 21ffaeb07..c89b8c5a7 100644
--- a/src/plugins/scripts/perl/weechat-perl.c
+++ b/src/plugins/scripts/perl/weechat-perl.c
@@ -34,6 +34,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "../../weechat-plugin.h"
#include "../weechat-script.h"
@@ -1631,7 +1633,8 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
STRLEN len;
t_plugin_script tempscript;
int eval;
-
+ struct stat buf;
+
#ifndef MULTIPLICITY
char pkgname[64];
#else
@@ -1640,8 +1643,16 @@ weechat_perl_load (t_weechat_plugin *plugin, char *filename)
#endif
plugin->print_server (plugin, "Loading Perl script \"%s\"", filename);
- perl_current_script = NULL;
+
+ if (stat (filename, &buf) != 0)
+ {
+ plugin->print_server (plugin, "Perl error: script \"%s\" not found",
+ filename);
+ return 0;
+ }
+ perl_current_script = NULL;
+
#ifndef MULTIPLICITY
snprintf(pkgname, sizeof(pkgname), "%s%d", PKG_NAME_PREFIX, perl_num);
perl_num++;
diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c
index c8091260d..a894f82b0 100644
--- a/src/plugins/scripts/python/weechat-python.c
+++ b/src/plugins/scripts/python/weechat-python.c
@@ -1592,14 +1592,13 @@ weechat_python_load (t_weechat_plugin *plugin, char *filename)
if ((fp = fopen (filename, "r")) == NULL)
{
- plugin->print_server (plugin,
- "Python error: unable to open file \"%s\"",
+ plugin->print_server (plugin, "Python error: script \"%s\" not found",
filename);
return 0;
}
-
+
python_current_script = NULL;
-
+
/* PyEval_AcquireLock (); */
python_current_interpreter = Py_NewInterpreter ();
PySys_SetArgv(1, argv);
diff --git a/src/plugins/scripts/ruby/weechat-ruby.c b/src/plugins/scripts/ruby/weechat-ruby.c
index 5001c10d3..4e2cebf90 100644
--- a/src/plugins/scripts/ruby/weechat-ruby.c
+++ b/src/plugins/scripts/ruby/weechat-ruby.c
@@ -32,6 +32,8 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "../../weechat-plugin.h"
#include "../weechat-script.h"
@@ -1796,10 +1798,19 @@ weechat_ruby_load (t_weechat_plugin *plugin, char *filename)
char modname[64];
VALUE curModule, ruby_retcode, err;
int ruby_error;
+ struct stat buf;
plugin->print_server (plugin, "Loading Ruby script \"%s\"", filename);
+
+ if (stat (filename, &buf) != 0)
+ {
+ plugin->print_server (plugin, "Ruby error: script \"%s\" not found",
+ filename);
+ return 0;
+ }
+
ruby_current_script = NULL;
-
+
snprintf(modname, sizeof(modname), "%s%d", MOD_NAME_PREFIX, ruby_num);
ruby_num++;