]> git.pld-linux.org Git - packages/weechat.git/blob - weechat-0.4.0-ruby-2.0-crash.patch
- release 4 (by relup.sh)
[packages/weechat.git] / weechat-0.4.0-ruby-2.0-crash.patch
1 From 4fdbb83a079f24a742633fd4d02084911580c19c Mon Sep 17 00:00:00 2001
2 From: Sebastien Helleu <flashcode@flashtux.org>
3 Date: Fri, 22 Mar 2013 19:54:44 +0100
4 Subject: [PATCH] ruby: fix crash with Ruby 2.0: use one array for the last 6
5  arguments of function config_new_option (bug #31050)
6
7 ---
8  src/plugins/ruby/weechat-ruby-api.c | 38 +++++++++++++++++++------------------
9  1 file changed, 20 insertions(+), 18 deletions(-)
10
11 diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
12 index bbc2fbc..101caec 100644
13 --- a/src/plugins/ruby/weechat-ruby-api.c
14 +++ b/src/plugins/ruby/weechat-ruby-api.c
15 @@ -1333,28 +1333,21 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
16                                      VALUE description, VALUE string_values,
17                                      VALUE min, VALUE max, VALUE default_value,
18                                      VALUE value, VALUE null_value_allowed,
19 -                                    VALUE function_check_value,
20 -                                    VALUE data_check_value,
21 -                                    VALUE function_change,
22 -                                    VALUE data_change,
23 -                                    VALUE function_delete,
24 -                                    VALUE data_delete)
25 +                                    VALUE callbacks)
26  {
27      char *c_config_file, *c_section, *c_name, *c_type, *c_description;
28      char *c_string_values, *c_default_value, *c_value;
29      char *c_function_check_value, *c_data_check_value, *c_function_change;
30      char *c_data_change, *c_function_delete, *c_data_delete, *result;
31      int c_min, c_max, c_null_value_allowed;
32 -    VALUE return_value;
33 +    VALUE function_check_value, data_check_value, function_change, data_change;
34 +    VALUE function_delete, data_delete, return_value;
35  
36      API_FUNC(1, "config_new_option", API_RETURN_EMPTY);
37      if (NIL_P (config_file) || NIL_P (section) || NIL_P (name) || NIL_P (type)
38          || NIL_P (description) || NIL_P (string_values) || NIL_P (min)
39          || NIL_P (max) || NIL_P (default_value) || NIL_P (value)
40 -        || NIL_P (null_value_allowed) || NIL_P (function_check_value)
41 -        || NIL_P (data_check_value) || NIL_P (function_change)
42 -        || NIL_P (data_change) || NIL_P (function_delete)
43 -        || NIL_P (data_delete))
44 +        || NIL_P (null_value_allowed) || NIL_P (callbacks))
45          API_WRONG_ARGS(API_RETURN_EMPTY);
46  
47      Check_Type (config_file, T_STRING);
48 @@ -1368,12 +1361,21 @@ weechat_ruby_api_config_new_option (VALUE class, VALUE config_file,
49      Check_Type (default_value, T_STRING);
50      Check_Type (value, T_STRING);
51      Check_Type (null_value_allowed, T_FIXNUM);
52 -    Check_Type (function_check_value, T_STRING);
53 -    Check_Type (data_check_value, T_STRING);
54 -    Check_Type (function_change, T_STRING);
55 -    Check_Type (data_change, T_STRING);
56 -    Check_Type (function_delete, T_STRING);
57 -    Check_Type (data_delete, T_STRING);
58 +    Check_Type (callbacks, T_ARRAY);
59 +
60 +    /*
61 +     * due to a Ruby limitation (15 arguments max by function), we receive the
62 +     * the callbacks in an array of 6 strings (3 callbacks + 3 data)
63 +     */
64 +    if (RARRAY_LEN(callbacks) != 6)
65 +        API_WRONG_ARGS(API_RETURN_EMPTY);
66 +
67 +    function_check_value = rb_ary_entry (callbacks, 0);
68 +    data_check_value = rb_ary_entry (callbacks, 1);
69 +    function_change = rb_ary_entry (callbacks, 2);
70 +    data_change = rb_ary_entry (callbacks, 3);
71 +    function_delete = rb_ary_entry (callbacks, 4);
72 +    data_delete = rb_ary_entry (callbacks, 5);
73  
74      c_config_file = StringValuePtr (config_file);
75      c_section = StringValuePtr (section);
76 @@ -5915,7 +5917,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
77      API_DEF_FUNC(config_new, 3);
78      API_DEF_FUNC(config_new_section, 14);
79      API_DEF_FUNC(config_search_section, 2);
80 -    API_DEF_FUNC(config_new_option, 17);
81 +    API_DEF_FUNC(config_new_option, 12);
82      API_DEF_FUNC(config_search_option, 3);
83      API_DEF_FUNC(config_string_to_boolean, 1);
84      API_DEF_FUNC(config_option_reset, 2);
85 -- 
86 1.8.1.4
87
This page took 0.084083 seconds and 3 git commands to generate.