diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-05-20 13:33:47 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-05-20 13:33:47 +0000 |
commit | bbbf2ffd4d4a227e53c962bae927ede10a91adb4 (patch) | |
tree | 5bcb11c3fe9506c60663df04fcc3cf247ca9cfab /sal | |
parent | a565357d1d298c220401437544d735a2f2b1a8b9 (diff) |
INTEGRATION: CWS mhu18_DEV300 (1.3.288); FILE MERGED
2008/05/19 07:59:10 mhu 1.3.288.1: #b6702916# Fixed rtl_allocateMemory() round-up alignment.
Diffstat (limited to 'sal')
-rw-r--r-- | sal/rtl/source/alloc_global.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/sal/rtl/source/alloc_global.c b/sal/rtl/source/alloc_global.c index c64e1c026dfc..f85856d1a57a 100644 --- a/sal/rtl/source/alloc_global.c +++ b/sal/rtl/source/alloc_global.c @@ -7,7 +7,7 @@ * OpenOffice.org - a multi-platform office productivity suite * * $RCSfile: alloc_global.c,v $ - * $Revision: 1.4 $ + * $Revision: 1.5 $ * * This file is part of OpenOffice.org. * @@ -200,9 +200,15 @@ SAL_CALL rtl_allocateMemory (sal_Size n) int index = (size - 1) >> RTL_MEMALIGN_SHIFT; OSL_ASSERT(RTL_MEMALIGN >= sizeof(sal_Size)); + if (n >= SAL_MAX_SIZE - (RTL_MEMALIGN + RTL_MEMALIGN - 1)) + { + /* requested size too large for roundup alignment */ + return 0; + } + try_alloc: if (index < RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SHIFT) - addr = (char*)rtl_cache_alloc(g_alloc_table[index]); + addr = (char*)rtl_cache_alloc (g_alloc_table[index]); else addr = (char*)rtl_arena_alloc (gp_alloc_arena, &size); @@ -234,7 +240,7 @@ void SAL_CALL rtl_freeMemory (void * p) int index = (size - 1) >> RTL_MEMALIGN_SHIFT; if (index < RTL_MEMORY_CACHED_LIMIT >> RTL_MEMALIGN_SHIFT) - rtl_cache_free(g_alloc_table[index], addr); + rtl_cache_free (g_alloc_table[index], addr); else rtl_arena_free (gp_alloc_arena, addr, size); } |