Changeset 2fec14b


Ignore:
Timestamp:
Jan 19, 2010, 10:53:08 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
fde6d80
Parents:
0f8efe0
Message:
perlglue.xs: Copy passed-in SV*s before storing them.

Perl gives us a pointer to the same SV* that the caller was using, so
if the caller mutates it in some way after the call, it affects our
saved copy. This is definitely not what we want.

Reported-by: William Throwe <wthrowe@MIT.EDU>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • perlglue.xs

    r129e609 r2fec14b  
    179179                owl_function_start_question(line);
    180180
    181                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback));
     181                owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback));
    182182                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
    183183        }
     
    195195                owl_function_start_password(line);
    196196
    197                 owl_editwin_set_cbdata(owl_global_get_typwin(&g), SvREFCNT_inc(callback));
     197                owl_editwin_set_cbdata(owl_global_get_typwin(&g), newSVsv(callback));
    198198                owl_editwin_set_callback(owl_global_get_typwin(&g), owl_perlconfig_edit_callback);
    199199        }
     
    208208                        croak("Callback must be a subref");
    209209
    210                 owl_function_start_edit_win(line, owl_perlconfig_edit_callback, SvREFCNT_inc(callback));
     210                owl_function_start_edit_win(line, owl_perlconfig_edit_callback, newSVsv(callback));
    211211        }
    212212
     
    279279        {
    280280                s = owl_malloc(sizeof(owl_style));
    281                 owl_style_create_perl(s, name, object);
     281                owl_style_create_perl(s, name, sv_2mortal(newSVsv(object)));
    282282                owl_global_add_style(&g, s);
    283283        }
     
    444444                }
    445445                cmd.name = name;
    446                 cmd.cmd_perl = SvREFCNT_inc(func);
     446                cmd.cmd_perl = newSVsv(func);
    447447                cmd.summary = summary;
    448448                cmd.usage = usage;
     
    504504        SV * cb
    505505        CODE:
    506         owl_select_add_perl_io_dispatch(fd, mode, SvREFCNT_inc(cb));
     506        owl_select_add_perl_io_dispatch(fd, mode, newSVsv(cb));
    507507
    508508IV
Note: See TracChangeset for help on using the changeset viewer.