bug-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #25869] Registering untyped selector mutates existing selector


From: Truls Becken
Subject: [bug #25869] Registering untyped selector mutates existing selector
Date: Sun, 15 Mar 2009 11:22:48 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.7) Gecko/2009030719 GranParadiso/3.0.7

Follow-up Comment #1, bug #25869 (project gnustep):

Here is a more direct example, where three selectors with the same name, but
different types, are registered. Each time, the name string is replaced with a
new copy.

Attached is a patch that fixes this by moving everything related to the
new_name variable in __sel_register_typed_name inside the if (is_new) branch.


$ cat main.m 
#import <Foundation/Foundation.h>

int main (int argc, const char **argv)
{
        char *name = "test";

        NSLog(@"name ptr: %d", name);
        NSLog(@"register1");
        SEL sel1 = sel_register_typed_name(name, "@8@0:4");
        NSLog(@"%d %d %s", sel1, sel_get_name(sel1), sel_get_type(sel1));
        NSLog(@"register2");
        SEL sel2 = sel_register_typed_name(name, "v8@0:4");
        NSLog(@"%d %d %s", sel1, sel_get_name(sel1), sel_get_type(sel1));
        NSLog(@"%d %d %s", sel2, sel_get_name(sel2), sel_get_type(sel2));
        NSLog(@"register2");
        SEL sel3 = sel_register_typed_name(name, NULL);
        NSLog(@"%d %d %s", sel1, sel_get_name(sel1), sel_get_type(sel1));
        NSLog(@"%d %d %s", sel2, sel_get_name(sel2), sel_get_type(sel2));
        NSLog(@"%d %d %s", sel3, sel_get_name(sel3), sel_get_type(sel3));

        return 0;
}


$ make && obj/test
This is gnustep-make 2.0.8. Type 'make print-gnustep-make-help' for help.
Making all for tool test...
 Compiling file main.m ...
 Linking tool test ...
2009-03-15 11:20:02.145 test[26773] name ptr: 134515274
2009-03-15 11:20:02.149 test[26773] register1
2009-03-15 11:20:02.151 test[26773] 148128376 148754376 @8@0:4
2009-03-15 11:20:02.155 test[26773] register2
2009-03-15 11:20:02.158 test[26773] 148128376 148827072 @8@0:4
2009-03-15 11:20:02.161 test[26773] 148128368 148827072 v8@0:4
2009-03-15 11:20:02.164 test[26773] register2
2009-03-15 11:20:02.168 test[26773] 148128376 148826744 @8@0:4
2009-03-15 11:20:02.171 test[26773] 148128368 148826744 v8@0:4
2009-03-15 11:20:02.174 test[26773] 148128360 148826744 (null)

(file #17695)
    _______________________________________________________

Additional Item Attachment:

File name: sel_register_typed_name.diff   Size:1 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?25869>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]