certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi/libHLA HLAvariableArray.hh


From: certi-cvs
Subject: [certi-cvs] certi/libHLA HLAvariableArray.hh
Date: Tue, 04 Nov 2008 14:40:40 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     Petr Gotthard <gotthardp>       08/11/04 14:40:40

Modified files:
        libHLA         : HLAvariableArray.hh 

Log message:
        Fix SIGSEGV when realloc occurs during HLAASCIIstring::operator =

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/libHLA/HLAvariableArray.hh?cvsroot=certi&r1=1.2&r2=1.3

Patches:
Index: HLAvariableArray.hh
===================================================================
RCS file: /sources/certi/certi/libHLA/HLAvariableArray.hh,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- HLAvariableArray.hh 3 Nov 2008 11:10:58 -0000       1.2
+++ HLAvariableArray.hh 4 Nov 2008 14:40:39 -0000       1.3
@@ -11,7 +11,7 @@
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// $Id: HLAvariableArray.hh,v 1.2 2008/11/03 11:10:58 gotthardp Exp $
+// $Id: HLAvariableArray.hh,v 1.3 2008/11/04 14:40:39 gotthardp Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _HLATYPES_VARIABLEARRAY_HH
@@ -218,8 +218,12 @@
 {
     HLAASCIIstring& operator = (const std::string& it)
     {
+        __HLAbuffer& buffer = __HLAbuffer::__buffer(this);
+        size_t offset = (char*)this - buffer.mBegin;
+
         set_size(it.size());
-        memcpy((char*)this + emptysizeof(), it.data(), it.size());
+        // note: set_size may have caused realloc()
+        memcpy(buffer.mBegin + offset + emptysizeof(), it.data(), it.size());
 
         return *this;
     }
@@ -237,5 +241,5 @@
 
 #endif // _HLATYPES_VARIABLEARRAY_HH
 
-// $Id: HLAvariableArray.hh,v 1.2 2008/11/03 11:10:58 gotthardp Exp $
+// $Id: HLAvariableArray.hh,v 1.3 2008/11/04 14:40:39 gotthardp Exp $
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]