mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
Fix possible memory corruption in string handling
This commit is contained in:
parent
49ba7d1ed1
commit
a377a86094
3 changed files with 16 additions and 8 deletions
|
@ -80,13 +80,13 @@ static inline void free_string(unichar **buf)
|
|||
*
|
||||
* Buffers created in this way are exception safe when using native exceptions.
|
||||
*/
|
||||
#define TEMP_BUFFER(name, size)\
|
||||
#define TEMP_BUFFER(name, length)\
|
||||
__attribute__((cleanup(free_string))) unichar *name ##_onheap = 0;\
|
||||
unichar name ## _onstack[64 / sizeof(unichar)];\
|
||||
unichar name ## _onstack[64];\
|
||||
unichar *name = name ## _onstack;\
|
||||
if (size > 64)\
|
||||
if (length > 64)\
|
||||
{\
|
||||
name ## _onheap = malloc(size);\
|
||||
name ## _onheap = malloc(length * sizeof(unichar));\
|
||||
name = name ## _onheap;\
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue