diff options
author | ayers <ayers@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-24 23:37:24 +0000 |
---|---|---|
committer | ayers <ayers@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-24 23:37:24 +0000 |
commit | 0f15169821ebe32980973375c7f049e1ce6a0da0 (patch) | |
tree | de0c99688b8eff2a3596b21c0a9f5f90a1728320 /libobjc | |
parent | 9c97629c71b58dce735b54e260c661ab4c6b9d3e (diff) | |
download | gcc-0f15169821ebe32980973375c7f049e1ce6a0da0.tar.gz |
2006-01-24 David Ayers <d.ayers@inode.at>
PR libobjc/9751
* gc.c (class_ivar_set_gcinvisible): Replace strncpy with memcpy
and insure the new strings are '\0' termintated.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@110187 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libobjc')
-rw-r--r-- | libobjc/ChangeLog | 6 | ||||
-rw-r--r-- | libobjc/gc.c | 20 |
2 files changed, 18 insertions, 8 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog index e8fdc1591cc..910ae986922 100644 --- a/libobjc/ChangeLog +++ b/libobjc/ChangeLog @@ -1,5 +1,11 @@ 2006-01-24 David Ayers <d.ayers@inode.at> + PR libobjc/9751 + * gc.c (class_ivar_set_gcinvisible): Replace strncpy with memcpy + and insure the new strings are '\0' termintated. + +2006-01-24 David Ayers <d.ayers@inode.at> + PR libobjc/13946 * configure.ac: Add include directives for --enable-objc-gc. * Makefile.in: Ditto. diff --git a/libobjc/gc.c b/libobjc/gc.c index 399d1aa8d73..51019993f3d 100644 --- a/libobjc/gc.c +++ b/libobjc/gc.c @@ -397,30 +397,34 @@ class_ivar_set_gcinvisible (Class class, const char *ivarname, if (*type == _C_GCINVISIBLE) { char *new_type; + size_t len; if (gc_invisible || ! __objc_ivar_pointer (type)) return; /* The type of the variable already matches the requested gc_invisible type */ - /* The variable is gc_invisible and we have to reverse it */ - new_type = objc_atomic_malloc (strlen (ivar->ivar_type)); - strncpy (new_type, ivar->ivar_type, - (size_t)(type - ivar->ivar_type)); + /* The variable is gc_invisible so we make it gc visible. */ + new_type = objc_atomic_malloc (strlen(ivar->ivar_type)); + len = (type - ivar->ivar_type); + memcpy (new_type, ivar->ivar_type, len); + new_type[len] = 0; strcat (new_type, type + 1); ivar->ivar_type = new_type; } else { char *new_type; + size_t len; if (! gc_invisible || ! __objc_ivar_pointer (type)) return; /* The type of the variable already matches the requested gc_invisible type */ - /* The variable is gc visible and we have to make it gc_invisible */ - new_type = objc_malloc (strlen (ivar->ivar_type) + 2); - strncpy (new_type, ivar->ivar_type, - (size_t)(type - ivar->ivar_type)); + /* The variable is gc visible so we make it gc_invisible. */ + new_type = objc_malloc (strlen(ivar->ivar_type) + 2); + len = (type - ivar->ivar_type); + memcpy (new_type, ivar->ivar_type, len); + new_type[len] = 0; strcat (new_type, "!"); strcat (new_type, type); ivar->ivar_type = new_type; |