diff options
author | Fabian Kosmale <fabian.kosmale@qt.io> | 2021-05-28 10:27:24 +0200 |
---|---|---|
committer | Robert Löhning <robert.loehning@qt.io> | 2021-05-28 13:38:45 +0000 |
commit | b140d12fca7228e6234c2acd7d3c1a17d0cb850f (patch) | |
tree | 86c3e0a305d6425d130c17d059a179c8d8ff3997 /src/qml | |
parent | 4344223a11bd2d6a494e6ddbe2949a291b4f97c8 (diff) |
QV4StackFrame: Fix ubsan warning
Calling memcpy with a nullptr is UB, even if we copy 0 bytes. Add a
null check to avoid the issue.
Fixes: QTBUG-94067
Change-Id: I1d47424754e22f13d7b494ae984b4407b96b1805
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
(cherry picked from commit 0b10b83dad91b44559b9f4ddcf9d8bed5544de93)
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/jsruntime/qv4stackframe_p.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4stackframe_p.h b/src/qml/jsruntime/qv4stackframe_p.h index 616fa9a5a9..9b6b5322bd 100644 --- a/src/qml/jsruntime/qv4stackframe_p.h +++ b/src/qml/jsruntime/qv4stackframe_p.h @@ -134,7 +134,9 @@ struct Q_QML_EXPORT CppStackFrame { argc = nFormals; jsFrame->setArgc(argc); - memcpy(jsFrame->args, originalArguments, argc*sizeof(Value)); + // memcpy requires non-null ptr, even if argc*sizeof(Value) == 0 + if (originalArguments) + memcpy(jsFrame->args, originalArguments, argc*sizeof(Value)); Q_STATIC_ASSERT(Encode::undefined() == 0); memset(jsFrame->args + argc, 0, (nRegisters - argc)*sizeof(Value)); |