Make sure type strings are nul terminated.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@26119 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2008-02-22 12:59:30 +00:00
parent b3417764f6
commit 9b8cdcf311
5 changed files with 46 additions and 14 deletions

View file

@ -170,13 +170,24 @@
if (_info == 0)
{
const char *types = _methodTypes;
char *outTypes;
unsigned int i;
_info = NSZoneMalloc(NSDefaultMallocZone(),
sizeof(NSArgumentInfo)*(_numArgs+1));
/* Allocate space enough for an NSArgumentInfo structure for each
* argument (including the return type), and enough space to hold
* the type information for each argument as a nul terminated
* string.
*/
outTypes = NSZoneMalloc(NSDefaultMallocZone(),
sizeof(NSArgumentInfo)*(_numArgs+1) + strlen(types)*2);
_info = (NSArgumentInfo*)outTypes;
outTypes = outTypes + sizeof(NSArgumentInfo)*(_numArgs+1);
/* Fill in the full argment information for each arg.
*/
for (i = 0; i <= _numArgs; i++)
{
types = mframe_next_arg(types, &_info[i]);
types = mframe_next_arg(types, &_info[i], outTypes);
outTypes += strlen(outTypes) + 1;
}
}
return _info;