OSSP CVS Repository

ossp - Check-in [3345]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3345
Date: 2003-May-19 21:03:06 (local)
2003-May-19 19:03:06 (UTC)
User:ms
Branch:
Comment: Use strlen only on condition of a valid incoming pointer.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_sect.c      1.6 -> 1.7     10 inserted, 6 deleted

ossp-pkg/rc/rc_sect.c 1.6 -> 1.7

--- rc_sect.c    2003/05/16 18:43:31     1.6
+++ rc_sect.c    2003/05/19 19:03:06     1.7
@@ -66,14 +66,18 @@
     pSec->m_Bytes   = pOrigsec->m_Bytes;
 
     /* Deep copy of user name */
-    pSec->m_szLogin = malloc((strlen(pOrigsec->m_szLogin) + sizeof(char))\
-        * sizeof(char));
-    strcpy(pSec->m_szLogin, pOrigsec->m_szLogin);
+    if (pOrigsec->m_szLogin) {
+        pSec->m_szLogin = malloc((strlen(pOrigsec->m_szLogin) + sizeof(char))\
+            * sizeof(char));
+        strcpy(pSec->m_szLogin, pOrigsec->m_szLogin);
+    }
 
     /* Deep copy of section text */
-    pSec->m_szData  = malloc((strlen(pOrigsec->m_szData) + sizeof(char))\
-        * sizeof(char));
-    strcpy(pSec->m_szData, pOrigsec->m_szData);
+    if (pOrigsec->m_szData) {
+        pSec->m_szData  = malloc((strlen(pOrigsec->m_szData) + sizeof(char))\
+            * sizeof(char));
+        strcpy(pSec->m_szData, pOrigsec->m_szData);
+    }
 
     if (!pSec)
         RC_THROW(RC_ERR_MEM);

CVSTrac 2.0.1