$B%a%b%j%j!<%/5M$a9g$o$;(B

e$BIMCO$G$9!#e(B

e$B$$$/$D$+%a%b%j%j!<%/$r8+$D$1$?$N$GJs9p$7$F$*$-$^$9!#e(B
e$B=EMW$J$N$Oe(B transcode.c e$B$@$1$+$H;W$$$^$9!#e(B

  • test/ruby/test_transcode.rb

e$BFs2U=j%j!<%/$7$F$k$+$J$H;W$$$^$9!#e(B
e$B0l2U=j$Oe(B trans_open_i e$B$+$i$+$($C$F$-$?e(B
entries e$B$r2rJ|$7$F$J$$$b$N$G!"e(B

“\x8f\xbc\x96\x7b\x8d\x73\x8d\x4f”.encode(‘utf-8’, ‘shift_jis’)

e$B$"$?$j$G:F8=$7$^$9!#e(B

e$B$b$&0l2U=j$Oe(B in_buf_start e$B$r2rJ|$7$F$J$$$b$N$G!"e(B

“\xA1\xA1\xFF”.encode(“ISO-2022-JP”, “EUC-JP”, invalid: :replace)

e$B$"$?$j$G:F8=$7$^$7$?!#e(B

  • test/strscan/test_strscan.rb

require ‘strscan’
ss = StringScanner.new(“\xA1\xA2”.force_encoding(“euc-jp”))
t = ss.scan(/./)

e$B$G%j!<%/$7$^$9!#e(B re.c e$B$r$^$M$7$F=$@5$7$F$_$^$7$?$,!"e(B
e$B$3$l$G@5$7$$$+$O$h$/$o$+$C$F$^$;$s!#e(B

  • test/openssl/*

e$B$"$A$3$A$G%j!<%/$7$F$k$]$$$N$G$9$,!"e(B

e$B$H$j$"$($:<j7Z$KL$KF~$C$?Fs2U=j$r=$@5$7$F$*$-$^$7$?!#e(B

e$B$D$$$G$K%X%s$J$b$N$r:n$C$?$N$G>R2p$5$;$F$/$@$5$$!#e(B
valgrind e$B$N=PNO$Ke(B Ruby e$B$G$I$N9T$r<B9T$7$?;~$Ke(B
e$B3NJ]$7$?%a%b%j$J$N$+$r:.$<$F=PNO$5$;$k$b$N$r:n$j$^$7$?!#e(B
e$B$[$I$[$I$K$OF0$$$F$k$_$?$$$G$9!#e(B

http://d.hatena.ne.jp/shinichiro_h/20080817#1218922824

Index: ext/openssl/ossl_config.c

— ext/openssl/ossl_config.c (revision 18709)
+++ ext/openssl/ossl_config.c (working copy)
@@ -443,8 +443,10 @@
eConfigError = rb_define_class_under(mOSSL, “ConfigError”,
eOSSLError);
cConfig = rb_define_class_under(mOSSL, “Config”, rb_cObject);

  • const char *default_config_file = CONF_get1_default_config_file();
    rb_define_const(cConfig, “DEFAULT_CONFIG_FILE”,
  •    rb_str_new2(CONF_get1_default_config_file()));
    
  •    rb_str_new2(default_config_file));
    
  • OPENSSL_free(default_config_file);
    rb_include_module(cConfig, rb_mEnumerable);
    rb_define_singleton_method(cConfig, “parse”, ossl_config_s_parse,
    1);
    rb_define_alias(CLASS_OF(cConfig), “load”, “new”);
    Index: ext/openssl/ossl_x509ext.c
    ===================================================================
    — ext/openssl/ossl_x509ext.c (revision 18709)
    +++ ext/openssl/ossl_x509ext.c (working copy)
    @@ -331,6 +331,7 @@
    ASN1_OCTET_STRING_free(asn1s);
    ossl_raise(eX509ExtError, NULL);
    }
  • free(s);
    GetX509Ext(self, ext);
    X509_EXTENSION_set_data(ext, asn1s);

Index: ext/strscan/strscan.c

— ext/strscan/strscan.c (revision 18709)
+++ ext/strscan/strscan.c (working copy)
@@ -407,6 +407,7 @@
struct strscanner *p;
regex_t *re;
int ret;

  • int tmpreg;

    Check_Type(regex, T_REGEXP);
    GET_SCANNER(self, p);
    @@ -416,6 +417,9 @@
    return Qnil;
    }
    re = rb_reg_prepare_re(regex, p->str);

  • tmpreg = re != RREGEXP(regex)->ptr;

  • if (!tmpreg) RREGEXP(regex)->usecnt++;

  • if (headonly) {
    ret = onig_match(re, (UChar* )CURPTR(p),
    (UChar* )(CURPTR(p) + S_RESTLEN(p)),
    @@ -427,6 +431,16 @@
    (UChar* )CURPTR(p), (UChar* )(CURPTR(p) +
    S_RESTLEN(p)),
    &(p->regs), ONIG_OPTION_NONE);
    }

  • if (!tmpreg) RREGEXP(re)->usecnt–;

  • if (tmpreg) {

  •    if (RREGEXP(regex)->usecnt) {
    
  •        onig_free(re);
    
  •    }
    
  •    else {
    
  •        onig_free(RREGEXP(regex)->ptr);
    
  •        RREGEXP(regex)->ptr = re;
    
  •    }
    
  • }

    if (ret == -2) rb_raise(ScanError, “regexp buffer overflow”);
    if (ret < 0) {
    Index: transcode.c
    ===================================================================
    — transcode.c (revision 18709)
    +++ transcode.c (working copy)
    @@ -743,14 +743,18 @@

    num_trans = transcode_search_path(from, to, trans_open_i, (void
    *)&entries);

  • if (num_trans < 0 || !entries)
  • if (num_trans < 0 || !entries) {

  •    xfree(entries);
       return NULL;
    
  • }

    if (flags & (ECONV_CRLF_NEWLINE_ENCODER|ECONV_CR_NEWLINE_ENCODER))
    {
    const char *name = (flags & ECONV_CRLF_NEWLINE_ENCODER) ?
    “crlf_newline” : “cr_newline”;
    transcoder_entry_t *e = get_transcoder_entry(“”, name);

  •    if (!e)
    
  •    if (!e) {
    
  •        xfree(entries);
           return NULL;
    
  •    }
       MEMMOVE(entries+1, entries, transcoder_entry_t *, num_trans);
       entries[0] = e;
       num_trans++;
    

@@ -758,12 +762,15 @@

 if (flags & ECONV_UNIVERSAL_NEWLINE_DECODER) {
     transcoder_entry_t *e = 

get_transcoder_entry(“universal_newline”, “”);

  •    if (!e)
    
  •    if (!e) {
    
  •        xfree(entries);
           return NULL;
    
  •    }
       entries[num_trans++] = e;
    

    }

    ec = rb_econv_open_by_transcoder_entries(num_trans, entries);

  • xfree(entries);
    if (!ec)
    rb_raise(rb_eArgError, “encoding conversion not supported (from
    %s to %s)”, from, to);

@@ -1200,7 +1207,7 @@
if (ec->elems[i].out_buf_start)
xfree(ec->elems[i].out_buf_start);
}

  • xfree(ec->in_buf_start);
    xfree(ec->elems);
    xfree(ec);
    }

In article [email protected],
shinichiro.h [email protected] writes:

e$B$$$/$D$+%a%b%j%j!<%/$r8+$D$1$?$N$GJs9p$7$F$*$-$^$9!#e(B
e$B=EMW$J$N$Oe(B transcode.c e$B$@$1$+$H;W$$$^$9!#e(B

  • test/ruby/test_transcode.rb

e$BFs2U=j%j!<%/$7$F$k$+$J$H;W$$$^$9!#e(B

e$B$?$7$+$K!#$"$F$F$F$*$-$^$7$?!#e(B