From fae89449915d777f034f8713103cf750cc3159ae Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Mon, 4 Dec 2023 16:23:02 +0800 Subject: [PATCH] feature add assert --- src/plugins/c/items/c_item_string.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plugins/c/items/c_item_string.cpp b/src/plugins/c/items/c_item_string.cpp index 91eac79..a0fbab5 100644 --- a/src/plugins/c/items/c_item_string.cpp +++ b/src/plugins/c/items/c_item_string.cpp @@ -54,6 +54,7 @@ CItemString::GenerateSetterDefinition(std::string message_id) const std::stringstream ss; // set_xxx_data ss << "void " << message_id << "_set_" << id() << "_data(" << message_id << "* message, const void* " << id() << ", int32_t " << id() << "_len) {" << std::endl; + ss << " assert(" << id() << " || " << id() << "_len == 0);" << std::endl; ss << " char* new_" << id() << " = (char*)malloc(" << id() << "_len + 1);" << std::endl; ss << " if (new_" << id() << " == NULL) { return; }" << std::endl; ss << " memcpy(new_" << id() << ", " << id() << ", " << id() << "_len);" << std::endl;