Changeset 7fd450f


Ignore:
Timestamp:
Mar 1, 2010, 8:33:47 PM (10 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
release-1.5
Children:
7d6a751
Parents:
65fca7a0
git-author:
Nelson Elhage <nelhage@mit.edu> (01/19/10 22:53:08)
git-committer:
Nelson Elhage <nelhage@mit.edu> (03/01/10 20:33:47)
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 r7fd450f  
    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.