mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Fix sizing structures in cifframe
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@14437 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
16a2ec7128
commit
860d398fb4
3 changed files with 13 additions and 4 deletions
|
@ -95,7 +95,6 @@
|
|||
#include <Foundation/NSZone.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
|
||||
|
||||
/*
|
||||
* Try to get more memory - the normal process has failed.
|
||||
* If we can't do anything, bomb out.
|
||||
|
|
|
@ -100,7 +100,10 @@ cifframe_guess_struct_size(ffi_type *stype)
|
|||
i = 0;
|
||||
while (stype->elements[i])
|
||||
{
|
||||
size += stype->elements[i]->size;
|
||||
if (stype->elements[i]->elements)
|
||||
size += cifframe_guess_struct_size(stype->elements[i]);
|
||||
else
|
||||
size += stype->elements[i]->size;
|
||||
|
||||
if (size % align != 0)
|
||||
{
|
||||
|
@ -173,7 +176,7 @@ cifframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
|
|||
* make room for it at the end of the cifframe so we
|
||||
* only need to do a single malloc.
|
||||
*/
|
||||
if (retval)
|
||||
if (rtype && rtype->size > 0)
|
||||
{
|
||||
unsigned full = size;
|
||||
unsigned pos;
|
||||
|
@ -188,7 +191,7 @@ cifframe_from_info (NSArgumentInfo *info, int numargs, void **retval)
|
|||
else
|
||||
full += MAX(rtype->size, sizeof(smallret_t));
|
||||
cframe = buf = NSZoneCalloc(NSDefaultMallocZone(), full, 1);
|
||||
if (cframe)
|
||||
if (cframe && retval)
|
||||
{
|
||||
*retval = buf + pos;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue