From b0deb820850eebcbaea1e5f76bb9720e2b822ea4 Mon Sep 17 00:00:00 2001 From: Richard Frith-Macdonald Date: Thu, 17 Jul 2003 13:26:39 +0000 Subject: [PATCH] Minor crash fix git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@17250 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 2 ++ Source/x11/XGServerWindow.m | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index ce58e1b..016ee80 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ 2003-07-27 Richard Frith-Macdonald * Tools/gpbs.m: Use protocols + * Source/x11/XGServerWindow.m: Use UTF8String rather than cString + to avoid crashes using non-ascii strings ... is this right? 2003-07-16 Fred Kiefer diff --git a/Source/x11/XGServerWindow.m b/Source/x11/XGServerWindow.m index 5805ac7..5444b0a 100644 --- a/Source/x11/XGServerWindow.m +++ b/Source/x11/XGServerWindow.m @@ -707,7 +707,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, XClassHint classhint; XTextProperty windowName; NSUserDefaults *defs; - const char *host_name = [[pInfo hostName] cString]; + const char *host_name = [[pInfo hostName] UTF8String]; /* * Initialize time of last events to be the start of time - not @@ -790,11 +790,10 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, */ if (rootName == 0) { - NSString *str; - str = [pInfo processName]; - i = [str cStringLength]; - rootName = objc_malloc(i+1); - [str getCString: rootName]; + const char *str = [[pInfo processName] UTF8String]; + + rootName = objc_malloc(strlen(str) + 1); + strcpy(rootName, str); } classhint.res_name = rootName; classhint.res_class = "GNUstep"; @@ -823,7 +822,7 @@ NSDebugLLog(@"Frame", @"X2O %d, %@, %@", win->number, argv = (char**)objc_malloc(argc*sizeof(char*)); for (i = 0; i < argc; i++) { - argv[i] = (char*)[[args objectAtIndex: i] cString]; + argv[i] = (char*)[[args objectAtIndex: i] UTF8String]; } XSetCommand(dpy, ROOT, argv, argc); objc_free(argv);