You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2020/02/10 09:04:10 UTC

[logging-log4cxx] 03/07: Fix abnormal termination fault in socketservertestcase. Remove C++11 code.

This is an automated email from the ASF dual-hosted git repository.

tschoening pushed a commit to branch ghpr_14_replace-ant-build-with-cmake
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git

commit 13a1eed677dd23ab9cfd98c37b5476a67eea767b
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Mon Feb 10 17:10:43 2020 +1100

    Fix abnormal termination fault in socketservertestcase. Remove C++11 code.
---
 src/test/cpp/net/socketserverstarter.cpp | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/src/test/cpp/net/socketserverstarter.cpp b/src/test/cpp/net/socketserverstarter.cpp
index fbb24c4..a8c2ae0 100644
--- a/src/test/cpp/net/socketserverstarter.cpp
+++ b/src/test/cpp/net/socketserverstarter.cpp
@@ -72,13 +72,13 @@ public:
           // convert the space separated cmd string to the argument list
           //
           static const int MaxArgumentCount = 14;
-          char** argv = (char**)apr_palloc(pool, MaxArgumentCount + 1 * sizeof(*argv));
+          char** argv = (char**)apr_palloc(pool, (MaxArgumentCount + 1) * sizeof(*argv));
           char* pcmd = apr_pstrdup(pool, cmd);
           int i = 0;
-          char separ = ' ';
           for (; i < MaxArgumentCount && pcmd && *pcmd; ++i)
           {
-              while(' ' == *pcmd)
+              char separ = ' ';
+              while(separ == *pcmd)
               {
                 *pcmd = 0;
                 ++pcmd;
@@ -88,8 +88,6 @@ public:
                  separ = *pcmd;
                  ++pcmd;
               }
-              else
-                separ = ' ';
               argv[i] = pcmd;
               if (NULL != (pcmd = strchr(pcmd, separ)))
               {
@@ -123,12 +121,14 @@ public:
               params.push_back(std::string());
               std::string& line = params.back();
               std::getline(in, line);
-              while (!line.empty() && ' ' == line.back())
-                 line.pop_back();
+              while (!line.empty() && (' ' == line[0] || '\t' == line[0]))
+                 line.erase(0, 1);
+              while (!line.empty() && (' ' == line[line.size() - 1] || '\t' == line[line.size() - 1]))
+                 line.erase(line.size() - 1, 1);
               if (line.empty())
                   params.pop_back();
           }
-          const char** argv = (const char**)apr_palloc(pool, params.size() + 1 * sizeof(*argv));
+          const char** argv = (const char**)apr_palloc(pool, (params.size() + 1) * sizeof(*argv));
           int i = 0;
           for (; i < params.size(); ++i)
           {