diff --git a/libunwind/src/UnwindLevel1-gcc-ext.c b/libunwind/src/UnwindLevel1-gcc-ext.c index d343f4e6e9cc83..32c872ffade1fd 100644 --- a/libunwind/src/UnwindLevel1-gcc-ext.c +++ b/libunwind/src/UnwindLevel1-gcc-ext.c @@ -143,7 +143,7 @@ _Unwind_Backtrace(_Unwind_Trace_Fn callback, void *ref) { // Create a mock exception object for force unwinding. _Unwind_Exception ex; memset(&ex, '\0', sizeof(ex)); - strcpy((char *)&ex.exception_class, "CLNGUNW"); + memcpy(&ex.exception_class, "CLNGUNW", sizeof(ex.exception_class)); #endif // walk each frame diff --git a/libunwind/test/forceunwind.pass.cpp b/libunwind/test/forceunwind.pass.cpp index 8c26551b6d0b67..db499d8bc30894 100644 --- a/libunwind/test/forceunwind.pass.cpp +++ b/libunwind/test/forceunwind.pass.cpp @@ -61,7 +61,7 @@ __attribute__((noinline)) void foo() { #if defined(_LIBUNWIND_ARM_EHABI) // Create a mock exception object. memset(e, '\0', sizeof(*e)); - strcpy(reinterpret_cast(&e->exception_class), "CLNGUNW"); + memcpy(&e->exception_class, "CLNGUNW", sizeof(e->exception_class)); #endif _Unwind_ForcedUnwind(e, stop, (void *)&foo); }