gnustep-dev
[Top][All Lists]
Advanced

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

Re: Range from String / String from Range problem


From: Riccardo Mottola
Subject: Re: Range from String / String from Range problem
Date: Fri, 13 Nov 2015 00:58:06 +0100
User-agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1

Hi Fred,

good catch ! Glad this one was spotted, it could impact many apps.

Fred Kiefer wrote:
The scanner in NSRangeFromString uses the method scanInt:, this is wrong
for 64bit systems. You could try to use scanInteger: instead and report
back. Just leave the method caching out while trying this if you have
problems with it.

you are right: the computer where it works is a 32bit system, the one where it fails is a 64bit one.

Do you intended a "quick patch" like the one below?

It appears to fix my issue.
Index: Source/NSRange.m
===================================================================
--- Source/NSRange.m    (revision 39168)
+++ Source/NSRange.m    (working copy)
@@ -73,11 +73,13 @@
   if ((*scanStringImp)(scanner, scanStringSel, @"{", NULL)
     && (*scanStringImp)(scanner, scanStringSel, @"location", NULL)
     && (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
-    && (*scanIntImp)(scanner, scanIntSel, (int*)&range.location)
+      && [scanner scanInteger: (NSInteger *)&range.location]
+      //    && (*scanIntImp)(scanner, scanIntSel, (int*)&range.location)
     && (*scanStringImp)(scanner, scanStringSel, @",", NULL)
     && (*scanStringImp)(scanner, scanStringSel, @"length", NULL)
     && (*scanStringImp)(scanner, scanStringSel, @"=", NULL)
-    && (*scanIntImp)(scanner, scanIntSel, (int*)&range.length)
+      && [scanner scanInteger: (NSInteger *)&range.length]
+      //    && (*scanIntImp)(scanner, scanIntSel, (int*)&range.length)
     && (*scanStringImp)(scanner, scanStringSel, @"}", NULL))
     return range;
   else

I see if i can fix the Imp caching myself, test it also on a 32bit machine and in case commit everything.

Riccardo




reply via email to

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