bug-gnustep
[Top][All Lists]
Advanced

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

[bug #28939] -[NSString getCString:] doesn't work


From: Sergey Golovin
Subject: [bug #28939] -[NSString getCString:] doesn't work
Date: Sat, 20 Feb 2010 09:07:52 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; ru; rv:1.9.1.7) Gecko/20100106 Ubuntu/9.10 (karmic) Firefox/3.5.7

URL:
  <http://savannah.gnu.org/bugs/?28939>

                 Summary: -[NSString getCString:] doesn't work
                 Project: GNUstep
            Submitted by: svg
            Submitted on: Сбт 20 Фев 2010 13:07:52
                Category: Base/Foundation
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

The followed code makes segfault:
<------------------------------------------------------

#import <Foundation/Foundation.h>

int main(int argc, char **argv, char **env) {
  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

  NSString *str = [NSString stringWithString:@"string"];
  unsigned size = [str length] + 1;
  char *buf = malloc(size);

  memset(buf, 0, size);
  [str getCString: buf];
  //  [str getCString: buf maxLength:size encoding: [NSString
defaultCStringEncoding]];                                      
  NSLog(@"%s", buf);

  [pool release];

  return 0;
}

------------------------------------------------------>

The commented out line is a working hack (instead plain getCString) to avoid
the segmentation fault.

My originally intention is to get DBModeller working to create an EOModel.
gdl2 uses [NSString getCString:] in some places. I got the segfault everytime
I were trying to change the name of an entity had just created. 
Steps to reproduce (and to checking):
1) Run DBModeler
2) The Main menu -> Model -> New...
3) The Main menu -> Property -> Add Entity
4) Try to change new entity's name

I get rid of segfaults by that hack been applied to gdl2.




    _______________________________________________________

Reply to this item at:

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

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





reply via email to

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