You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2008/02/14 01:06:13 UTC

svn commit: r627617 - /stdcxx/trunk/src/iso2022.cpp

Author: sebor
Date: Wed Feb 13 16:06:04 2008
New Revision: 627617

URL: http://svn.apache.org/viewvc?rev=627617&view=rev
Log:
2008-02-13  Martin Sebor  <se...@roguewave.com>

	STDCXX-730
	* src/iso2022.cpp (__rw_iso2022jp_designate): Asserted preconditions
	to silence HP aCC  warning #20200-D: Potential null pointer dereference.
	(__rw_ucs4_to_interm): Corrected a bad conditional pointed out by HP
	aCC warning #20206-D: Out of bound access.

Modified:
    stdcxx/trunk/src/iso2022.cpp

Modified: stdcxx/trunk/src/iso2022.cpp
URL: http://svn.apache.org/viewvc/stdcxx/trunk/src/iso2022.cpp?rev=627617&r1=627616&r2=627617&view=diff
==============================================================================
--- stdcxx/trunk/src/iso2022.cpp (original)
+++ stdcxx/trunk/src/iso2022.cpp Wed Feb 13 16:06:04 2008
@@ -22,7 +22,7 @@
  * implied.   See  the License  for  the  specific language  governing
  * permissions and limitations under the License.
  *
- * Copyright 1994-2006 Rogue Wave Software.
+ * Copyright 1994-2008 Rogue Wave Software, Inc.
  * 
  **************************************************************************/
 
@@ -738,8 +738,12 @@
             if (_RWSTD_STATIC_CAST (_RWSTD_SIZE_T, to_end - to) < len)
                 return CODECVT_PARTIAL;
 
-            memcpy (to, esc, len);
-            to += len;
+            if (len) {
+                _RWSTD_ASSERT (to && esc);
+                
+                memcpy (to, esc, len);
+                to += len;
+            }
 
             // adjust the state
             state.g_map [2] = reg;
@@ -750,8 +754,12 @@
         if (_RWSTD_STATIC_CAST (_RWSTD_SIZE_T, to_end - to) < len)
             return CODECVT_PARTIAL;
 
-        memcpy (to, ss, sslen);
-        to += sslen;
+        if (sslen) {
+            _RWSTD_ASSERT (to && ss);
+
+            memcpy (to, ss, sslen);
+            to += sslen;
+        }
 
         // adjust the single shift indicator
         state.sshift2 = 1;
@@ -761,8 +769,12 @@
         if (_RWSTD_STATIC_CAST (_RWSTD_SIZE_T, to_end - to) < len)
             return CODECVT_PARTIAL;
 
-        memcpy (to, esc, len);
-        to += len;
+        if (len) {
+            _RWSTD_ASSERT (to && esc);
+
+            memcpy (to, esc, len);
+            to += len;
+        }
 
         // adjust the state
         state.g_map [0]   = reg;
@@ -1534,7 +1546,7 @@
     // utf8 temporary buffer
     char tmp [_UTF8_MB_CUR_MAX];
 
-    for (int i = 0; i < int(sizeof (db_array)/sizeof (unsigned char)); i++) {
+    for (size_t i = 0; i < sizeof db_array / sizeof *db_array; ++i) {
         char* ptmp = tmp;
 
         // obtain the database mapping