mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 06:46:38 +02:00
Fixed crash when loading ruby script if file does not exist, with Ruby >= 1.9 only (bug #18064)
This commit is contained in:
@@ -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 ();
|
||||
|
||||
@@ -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++;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user