From: Dimitris Papavasiliou Date: Fri, 9 Jan 2015 17:55:57 +0000 (+0000) Subject: ivars.c: Add a check for classes without instance variables... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=100bfe4a97e83c70098590e57c4f4f04d98c0837;p=gcc.git ivars.c: Add a check for classes without instance variables... 2015-01-09 Dimitris Papavasiliou * ivars.c: Add a check for classes without instance variables, which have a NULL ivar list pointer. 2015-01-09 Dimitris Papavasiliou * objc.dg/gnu-api-2-class.m: Add a test case for the above change. From-SVN: r219396 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index a529f192059..bdae8efa73b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-01-09 Dimitris Papavasiliou + + * objc.dg/gnu-api-2-class.m: Add a test case + for the above change. + 2015-01-09 Sebastian Huber * gcc.dg/typeof-2.c: Add checks for non-atomic types. diff --git a/gcc/testsuite/objc.dg/gnu-api-2-class.m b/gcc/testsuite/objc.dg/gnu-api-2-class.m index 7f9cf861c8a..341952969e8 100644 --- a/gcc/testsuite/objc.dg/gnu-api-2-class.m +++ b/gcc/testsuite/objc.dg/gnu-api-2-class.m @@ -239,6 +239,19 @@ int main(int argc, void **args) abort (); } + printf ("Testing class_copyIvarList () on class with no instance variables...\n"); + { + unsigned int count; + Ivar * list = class_copyIvarList (objc_getClass ("MyOtherSubClass"), + &count); + + if (count != 0) + abort (); + + if (list != NULL) + abort (); + } + printf ("Testing class_copyMethodList ()...\n"); { unsigned int count; diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index 2e2b543b2dc..a3f31b73023 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,3 +1,8 @@ +2015-01-09 Dimitris Papavasiliou + + * ivars.c: Add a check for classes without instance + variables, which have a NULL ivar list pointer. + 2015-01-05 Jakub Jelinek Update copyright years. diff --git a/libobjc/ivars.c b/libobjc/ivars.c index dd145360e39..910a09828db 100644 --- a/libobjc/ivars.c +++ b/libobjc/ivars.c @@ -179,7 +179,7 @@ struct objc_ivar ** class_copyIvarList (Class class_, unsigned int *numberOfRetu struct objc_ivar **returnValue = NULL; struct objc_ivar_list* ivar_list; - if (class_ == Nil || CLS_IS_IN_CONSTRUCTION (class_)) + if (class_ == Nil || CLS_IS_IN_CONSTRUCTION (class_) || !class_->ivars) { if (numberOfReturnedIvars) *numberOfReturnedIvars = 0;