From 0871d54a823943f3d94cd0d5089f1f99791b7030 Mon Sep 17 00:00:00 2001 From: gcasa Date: Wed, 24 Sep 2008 12:29:15 +0000 Subject: [PATCH] Explicitly roll over to zero when the element isn't found. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26870 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++++ Source/NSUserDefaults.m | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 86cbaea1a..6c4b2a250 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-09-24 08:25-EDT Gregory John Casamento + + * Source/NSUserDefaults.m: -addSuiteNamed change so that we don't + rely on the value of NSNotFound being -(2^32)-1 and a rollover to + 0. + 2008-09-23 20:31-EDT Gregory John Casamento * config.mak.in: Added reference to HAVE_OBJC_SYNC_ENTER diff --git a/Source/NSUserDefaults.m b/Source/NSUserDefaults.m index 6ecd16e00..ff04302b4 100644 --- a/Source/NSUserDefaults.m +++ b/Source/NSUserDefaults.m @@ -925,7 +925,10 @@ static BOOL setSharedDefaults = NO; /* Flag to prevent infinite recursion */ if (self == sharedDefaults) invalidatedLanguages = YES; [_searchList removeObject: aName]; index = [_searchList indexOfObject: processName]; - index++; // NSNotFound wraps to zero ... insert at start. + if(index == NSNotFound) + { + index = 0; // NSNotFound, insert at start. + } aName = [aName copy]; [_searchList insertObject: aName atIndex: index]; [_lock unlock];