summaryrefslogtreecommitdiff
path: root/ACE/ace/CDR_Stream.cpp
diff options
context:
space:
mode:
authorparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-08-07 20:23:07 +0000
committerparsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-08-07 20:23:07 +0000
commitb31aaa377282d63b9f4a6bd22f54257180fbad59 (patch)
tree371fd12f9a9711fab9676659ac3ebb0fe6073d94 /ACE/ace/CDR_Stream.cpp
parent08fff03cd764ca68f8a1bc35a82020ced9508e07 (diff)
downloadATCD-b31aaa377282d63b9f4a6bd22f54257180fbad59.tar.gz
ChangeLogTag: Thu Aug 7 20:21:29 UTC 2008 Jeff Parsons <j.parsons@vanderbilt.edu>
Diffstat (limited to 'ACE/ace/CDR_Stream.cpp')
-rw-r--r--ACE/ace/CDR_Stream.cpp27
1 files changed, 21 insertions, 6 deletions
diff --git a/ACE/ace/CDR_Stream.cpp b/ACE/ace/CDR_Stream.cpp
index 1acb6982937..d88168724a8 100644
--- a/ACE/ace/CDR_Stream.cpp
+++ b/ACE/ace/CDR_Stream.cpp
@@ -1,6 +1,7 @@
#include "ace/CDR_Stream.h"
#include "ace/SString.h"
#include "ace/Auto_Ptr.h"
+#include "ace/Truncate.h"
#if !defined (__ACE_INLINE__)
# include "ace/CDR_Stream.inl"
@@ -374,12 +375,21 @@ ACE_OutputCDR::write_wstring (ACE_CDR::ULong len,
//In GIOP 1.2 the length field contains the number of bytes
//the wstring occupies rather than number of wchars
//Taking sizeof might not be a good way! This is a temporary fix.
- if (this->write_ulong (ACE_OutputCDR::wchar_maxbytes_ * len))
- return this->write_wchar_array (x, len);
+ ACE_CDR::Boolean good_ulong =
+ this->write_ulong (
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (
+ ACE_OutputCDR::wchar_maxbytes_ * len));
+
+ if (good_ulong)
+ {
+ return this->write_wchar_array (x, len);
+ }
}
else
- //In GIOP 1.2 zero length wstrings are legal
- return this->write_ulong (0);
+ {
+ //In GIOP 1.2 zero length wstrings are legal
+ return this->write_ulong (0);
+ }
}
else
@@ -1361,8 +1371,11 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
}
ACE_CDR::ULong len = 0;
+
if (!this->read_ulong (len))
- return false;
+ {
+ return false;
+ }
// A check for the length being too great is done later in the
// call to read_char_array but we want to have it done before
@@ -1374,7 +1387,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
&& static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
{
- len /= ACE_OutputCDR::wchar_maxbytes_;
+ len /=
+ ACE_Utils::truncate_cast<ACE_CDR::ULong> (
+ ACE_OutputCDR::wchar_maxbytes_);
//allocating one extra for the null character needed by applications
ACE_NEW_RETURN (x,