# HG changeset patch # User Yasumasa Suenaga # Date 1478612083 -32400 # Node ID 00afdf817f775fe15f47f781eb67b08e73a3617e # Parent 387a6530ff43339051bdeced48c55260372f014e Bug 3223: Cannot set empty value to signal setting Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/47 diff -r 387a6530ff43 -r 00afdf817f77 ChangeLog --- a/ChangeLog Tue Nov 01 09:46:46 2016 +0900 +++ b/ChangeLog Tue Nov 08 22:34:43 2016 +0900 @@ -1,3 +1,7 @@ +2016-11-08 Yasumasa Suenaga + + * Bug 3223: Cannot set empty value to signal setting + 2016-10-31 KUBOTA Yuji * Bug 3214: heapstats-cli should check JAVA_HOME value diff -r 387a6530ff43 -r 00afdf817f77 agent/src/heapstats-engines/configuration.cpp --- a/agent/src/heapstats-engines/configuration.cpp Tue Nov 01 09:46:46 2016 +0900 +++ b/agent/src/heapstats-engines/configuration.cpp Tue Nov 08 22:34:43 2016 +0900 @@ -265,7 +265,11 @@ * \param dest [in] [out] Destination of this configuration. */ void TConfiguration::ReadSignalValue(const char *value, char **dest) { - if (value == NULL) { + if ((value == NULL) || (value[0] == '\0')) { + if (*dest != NULL) { + free(*dest); + } + *dest = NULL; } else if (isSupportSignal(value)) { if (*dest != NULL) { @@ -353,9 +357,9 @@ } #if USE_PCRE - TPCRERegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)\\s*$", 9); + TPCRERegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)?\\s*$", 9); #else - TCPPRegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)\\s*$"); + TCPPRegex confRegex("^\\s*(\\S+?)\\s*=\\s*(\\S+)?\\s*$"); #endif /* Get string line from configure file. */ @@ -382,7 +386,13 @@ if (confRegex.find(lineBuff)) { /* Key and value variables. */ char *key = confRegex.group(1); - char *value = confRegex.group(2); + char *value; + try { + value = confRegex.group(2); + } catch (const char *errStr) { + logger->printDebugMsg(errStr); + value = (char *)calloc(1, sizeof(char)); + } /* Check key name. */ try {