mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
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:
parent
b3417764f6
commit
9b8cdcf311
5 changed files with 46 additions and 14 deletions
|
@ -202,11 +202,14 @@ mframe_build_signature(const char *typePtr, int *size, int *narg, char *buf)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Step through method encoding information extracting details.
|
||||
/* Step through method encoding information extracting details.
|
||||
* If outTypes is non-nul then we copy the argument type into
|
||||
* the buffer as a nul terminated string and use the values in
|
||||
* this buffer as the types in info, rather than pointers to
|
||||
* positions in typePtr
|
||||
*/
|
||||
const char *
|
||||
mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
||||
mframe_next_arg(const char *typePtr, NSArgumentInfo *info, char *outTypes)
|
||||
{
|
||||
NSArgumentInfo local;
|
||||
BOOL flag;
|
||||
|
@ -354,7 +357,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
{
|
||||
typePtr++;
|
||||
}
|
||||
typePtr = mframe_next_arg(typePtr, &local);
|
||||
typePtr = mframe_next_arg(typePtr, &local, 0);
|
||||
info->size = length * ROUND(local.size, local.align);
|
||||
info->align = local.align;
|
||||
typePtr++; /* Skip end-of-array */
|
||||
|
@ -380,7 +383,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
*/
|
||||
if (*typePtr != _C_STRUCT_E)
|
||||
{
|
||||
typePtr = mframe_next_arg(typePtr, &local);
|
||||
typePtr = mframe_next_arg(typePtr, &local, 0);
|
||||
if (typePtr == 0)
|
||||
{
|
||||
return 0; /* error */
|
||||
|
@ -395,7 +398,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
*/
|
||||
while (*typePtr != _C_STRUCT_E)
|
||||
{
|
||||
typePtr = mframe_next_arg(typePtr, &local);
|
||||
typePtr = mframe_next_arg(typePtr, &local, 0);
|
||||
if (typePtr == 0)
|
||||
{
|
||||
return 0; /* error */
|
||||
|
@ -434,7 +437,7 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
}
|
||||
while (*typePtr != _C_UNION_E)
|
||||
{
|
||||
typePtr = mframe_next_arg(typePtr, &local);
|
||||
typePtr = mframe_next_arg(typePtr, &local, 0);
|
||||
if (typePtr == 0)
|
||||
{
|
||||
return 0; /* error */
|
||||
|
@ -462,6 +465,17 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Copy tye type information into the buffer if provided.
|
||||
*/
|
||||
if (outTypes != 0)
|
||||
{
|
||||
unsigned len = typePtr - info->type;
|
||||
|
||||
strncpy(outTypes, info->type, len);
|
||||
outTypes[len] = '\0';
|
||||
info->type = outTypes;
|
||||
}
|
||||
|
||||
/*
|
||||
* May tell the caller if the item is stored in a register.
|
||||
*/
|
||||
|
@ -499,7 +513,6 @@ mframe_next_arg(const char *typePtr, NSArgumentInfo *info)
|
|||
return typePtr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Return the number of arguments that the method MTH expects. Note
|
||||
that all methods need two implicit arguments `self' and `_cmd'. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue