summaryrefslogtreecommitdiff
path: root/ACE/ace/OS_NS_stdio.cpp
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2006-10-23 23:31:00 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2006-10-23 23:31:00 +0000
commit493991791e3c7232fa33f428177dbfc9b666adac (patch)
treef937218c26da44d35b11b3ddeee1804031b5d99a /ACE/ace/OS_NS_stdio.cpp
parentfe745d19b69bcac8e99ca5304656eada195cd1c6 (diff)
downloadATCD-493991791e3c7232fa33f428177dbfc9b666adac.tar.gz
ChangeLogTag:Mon Oct 23 02:28:42 UTC 2006 Ossama Othman <ossama_othman at symantec dot com>
Diffstat (limited to 'ACE/ace/OS_NS_stdio.cpp')
-rw-r--r--ACE/ace/OS_NS_stdio.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/ACE/ace/OS_NS_stdio.cpp b/ACE/ace/OS_NS_stdio.cpp
index bfcbad2d8e5..df92196644b 100644
--- a/ACE/ace/OS_NS_stdio.cpp
+++ b/ACE/ace/OS_NS_stdio.cpp
@@ -119,10 +119,17 @@ ACE_OS::fopen (const char *filename,
ACE_OS_TRACE ("ACE_OS::fopen");
int hmode = _O_TEXT;
- for (const ACE_TCHAR *mode_ptr = mode; *mode_ptr != 0; mode_ptr++)
+ // Let the chips fall where they may if the user passes in a NULL
+ // mode string. Convert to an empty mode string to prevent a
+ // crash.
+ ACE_TCHAR const empty_mode[] = ACE_TEXT ("");
+ if (!mode)
+ mode = empty_mode;
+
+ for (ACE_TCHAR const* mode_ptr = mode; *mode_ptr != 0; ++mode_ptr)
ACE_OS::fopen_mode_to_open_mode_converter (*mode_ptr, hmode);
- ACE_HANDLE handle = ACE_OS::open (filename, hmode);
+ ACE_HANDLE const handle = ACE_OS::open (filename, hmode);
if (handle != ACE_INVALID_HANDLE)
{
hmode &= _O_TEXT | _O_RDONLY | _O_APPEND;
@@ -132,13 +139,13 @@ ACE_OS::fopen (const char *filename,
if (fd != -1)
{
# if defined (__BORLANDC__) && !defined (ACE_USES_WCHAR)
- FILE *fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
+ FILE * const fp = ::_fdopen (fd, const_cast<ACE_TCHAR *> (mode));
# elif defined (__BORLANDC__) && defined (ACE_USES_WCHAR)
- FILE *fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
+ FILE * const fp = ::_wfdopen (fd, const_cast<ACE_TCHAR *> (mode));
# elif defined (ACE_USES_WCHAR)
- FILE *fp = ::_wfdopen (fd, mode);
+ FILE * const fp = ::_wfdopen (fd, mode);
# else
- FILE *fp = ::fdopen (fd, mode);
+ FILE * const fp = ::fdopen (fd, mode);
# endif /* defined(__BORLANDC__) && !defined (ACE_USES_WCHAR)) */
if (fp != 0)
{