From 077ab86056b1554be733a94001be4785fda978b0 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 7 Nov 2015 09:15:00 +0100 Subject: [PATCH] yield error when field name was specified but nothing else --- src/lib/ebus/data.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/ebus/data.cpp b/src/lib/ebus/data.cpp index 57155358..04d33e98 100644 --- a/src/lib/ebus/data.cpp +++ b/src/lib/ebus/data.cpp @@ -99,7 +99,7 @@ unsigned int parseInt(const char* str, int base, const unsigned int minValue, co unsigned long int ret = strtoul(str, &strEnd, base); - if (strEnd == NULL || strEnd == str|| *strEnd != 0) { + if (strEnd == NULL || strEnd == str || *strEnd != 0) { result = RESULT_ERR_INVALID_NUM; // invalid value return 0; } @@ -178,7 +178,7 @@ result_t DataField::create(vector::iterator& it, if (it == end) return RESULT_ERR_EOF; - do { + while (it != end && result == RESULT_OK) { string unit, comment; PartType partType; int divisor = 0; @@ -188,8 +188,11 @@ result_t DataField::create(vector::iterator& it, // template: name,type[:len][,[divisor|values][,[unit][,[comment]]]] // std: name,part,type[:len][,[divisor|values][,[unit][,[comment]]]] const string name = *it++; // name - if (it == end) + if (it == end) { + if (!name.empty()) + result = RESULT_ERR_MISSING_TYPE; break; + } if (isTemplate) partType = pt_any; @@ -307,7 +310,7 @@ result_t DataField::create(vector::iterator& it, } firstType = false; } - } while (it != end && result == RESULT_OK); + } if (result != RESULT_OK) { while (!fields.empty()) { // cleanup already created fields