Author: sebor
Date: Wed Apr  9 12:11:30 2008
New Revision: 646486

URL: http://svn.apache.org/viewvc?rev=646486&view=rev
Log:
2008-04-09  Martin Sebor  <[EMAIL PROTECTED]>

        STDCXX-749
        * util/time.cpp (parse_era): Checked the pointer returned from
        strtok() before dereferencing it and issued an error when it's
        null to silence HP aCC 6.16 potential null pointer dereference
        warning.

Modified:
    stdcxx/trunk/util/time.cpp

Modified: stdcxx/trunk/util/time.cpp
URL: 
http://svn.apache.org/viewvc/stdcxx/trunk/util/time.cpp?rev=646486&r1=646485&r2=646486&view=diff
==============================================================================
--- stdcxx/trunk/util/time.cpp (original)
+++ stdcxx/trunk/util/time.cpp Wed Apr  9 12:11:30 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 2001-2006 Rogue Wave Software.
+ * Copyright 2001-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -67,12 +67,24 @@
 
     // now get the offset
     tokp = std::strtok (0, ":");
+    if (0 == tokp)
+        issue_diag (E_SYNTAX, true, &tok,
+                    "expected ':' in era definition\n");
+
+    assert (0 != tokp);
+
     std::sscanf (tokp, "%d", &tmp_era.era_out.offset);
     if (direction == '-')
         tmp_era.era_out.offset *= -1;
     
     // now get the start date
     tokp = std::strtok (0, ":");
+    if (0 == tokp)
+        issue_diag (E_SYNTAX, true, &tok,
+                    "expected ':' in era definition\n");
+
+    assert (0 != tokp);
+
     unsigned int tmp_mon, tmp_day;
     std::sscanf (tokp, "%d/%u/%u", &tmp_era.era_out.year[0], 
                  &tmp_mon, &tmp_day);
@@ -83,6 +95,12 @@
 
     // now get the end date (this may be the beginning or end of time
     tokp = std::strtok (0, ":");
+    if (0 == tokp)
+        issue_diag (E_SYNTAX, true, &tok,
+                    "expected ':' in era definition\n");
+
+    assert (0 != tokp);
+
     if (std::strcmp (tokp, "-*") == 0) {
         tmp_era.era_out.year[1] = _RWSTD_INT_MIN;
         tmp_era.era_out.month[1] = _RWSTD_CHAR_MIN;


Reply via email to