# Enc\_register\_at should use strdup

**URL:** <https://www.ruby-forum.com/t/enc-register-at-should-use-strdup/126223>\
**Category:** Development\
**Created:** [January 16, 2008, 2:19pm UTC](https://www.ruby-forum.com/t/enc-register-at-should-use-strdup/126223 "2008-01-16T14:19:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sheepman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d07c76/32.png) [@sheepman](https://www.ruby-forum.com/u/sheepman)\
**Post date:** [January 16, 2008, 2:19pm UTC](https://www.ruby-forum.com/t/enc-register-at-should-use-strdup/126223/1 "2008-01-16T14:19:29Z")

</div>

e$B$3$s$P$s$Oe(B sheepman e$B$G$9!#e(B

e$B\<!$N$h$&$J%3!\<%I$G%(%i!\<$K$J$j$^$9!#e(B  
require e$B$O4X78$"$j$^$;$s!#%(%s%3!\<%G%#%s%0L\>$rI=$9J8;zNs$,e(B  
GC e$B$5$l$F$7$^$&$h$&$G$9!#e(B

$ cat t.rb  
#-_- coding: euc-jp -_-  
100.times do  
Encoding.find(“Windows” + “-1255”)  
require ‘drb’  
end

$ ruby-1.9 -v t.rb  
ruby 1.9.0 (2008-01-16 revision 0) [i686-linux]  
t.rb:3:in `find': unknown encoding name - Windows-1255 (ArgumentError) from t.rb:4:in`block in ’  
from t.rb:3:in `times' from t.rb:3:in`’

e$B0J2\<$O%Q%C%A$G$9!#e(B

# Index: encoding.c

— encoding.c (revision 15080)  
+++ encoding.c (working copy)  
@@ -146,11 +146,11 @@  
{  
struct rb\_encoding\_entry \*ent = &enc\_table.list[index];

- ent-\>name = name;

- ent-\>name = strdup(name);  
if (!ent-\>enc) ent-\>enc = malloc(sizeof(rb\_encoding));  
\*ent-\>enc = \*encoding;  
encoding = ent-\>enc;

- encoding-\>name = name;

- encoding-\>name = strdup(name);  
encoding-\>ruby\_encoding\_index = index;  
if (rb\_cEncoding) {  
/\* initialize encoding data \*/
