PrintfState includes std::string object and shouldn't be copied by malloc/memcpy.
Signed-off-by: Yan Wang <yan.w...@linux.intel.com> --- backend/src/ir/printf.hpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/backend/src/ir/printf.hpp b/backend/src/ir/printf.hpp index b9f7619..8ea5976 100644 --- a/backend/src/ir/printf.hpp +++ b/backend/src/ir/printf.hpp @@ -75,6 +75,23 @@ namespace gbe char conversion_specifier; int out_buf_sizeof_offset; // Should *global_total_size to get the full offset. std::string str; //if %s, the string store here. + + PrintfState(void) { + } + + PrintfState(const PrintfState & other) { + left_justified = other.left_justified; + sign_symbol = other.sign_symbol; + alter_form = other.alter_form; + zero_padding = other.zero_padding; + vector_n = other.vector_n; + min_width = other.min_width; + precision = other.precision; + length_modifier = other.length_modifier; + conversion_specifier = other.conversion_specifier; + out_buf_sizeof_offset = other.out_buf_sizeof_offset; + str = other.str; + } }; enum { @@ -106,8 +123,7 @@ namespace gbe PrintfSlot(PrintfState * st) { type = PRINTF_SLOT_TYPE_STATE; - state = (PrintfState *)malloc(sizeof(PrintfState)); - memcpy(state, st, sizeof(PrintfState)); + state = new PrintfState(*st); } PrintfSlot(const PrintfSlot & other) { @@ -119,8 +135,7 @@ namespace gbe type = PRINTF_SLOT_TYPE_STRING; } else if (other.type == PRINTF_SLOT_TYPE_STATE) { type = PRINTF_SLOT_TYPE_STATE; - state = (PrintfState *)malloc(sizeof(PrintfState)); - memcpy(state, other.state, sizeof(PrintfState)); + state = new PrintfState(*other.state); } else { type = PRINTF_SLOT_TYPE_NONE; ptr = NULL; -- 1.9.3 _______________________________________________ Beignet mailing list Beignet@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/beignet