From ca4128dfd14b7ff1a5a4ea211d8d329559cd9e73 Mon Sep 17 00:00:00 2001 From: ryanhuang Date: Wed, 22 Dec 2021 16:59:16 +0800 Subject: [PATCH] fix cursor.cc reading an empty string error when compile without "-o2" in "gcc version 8.4.1" --- dwarf/cursor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dwarf/cursor.cc b/dwarf/cursor.cc index 19902da..f5a4193 100644 --- a/dwarf/cursor.cc +++ b/dwarf/cursor.cc @@ -86,7 +86,9 @@ cursor::string(std::string &out) size_t size; const char *p = this->cstr(&size); out.resize(size); - memmove(&out.front(), p, size); + if (size > 0) { + memmove(&out.front(), p, size); + } } const char *