re PR libstdc++/24450 (Exception safety problem in messages/__timepunct)
2005-10-21 Paolo Carlini <pcarlini@suse.de> PR libstdc++/24450 * config/locale/generic/time_members.h (__timepunct<>:: __timepunct(__c_locale, const char*, size_t)): Avoid leaking memory if new throws inside _M_initialize_timepunct. * config/locale/gnu/time_members.h (__timepunct<>:: __timepunct(__c_locale, const char*, size_t)): Likewise. * config/locale/gnu/message_members.h (messages<>:: messages(__c_locale, const char*, size_t)): Rearrange to avoid memory leaks. From-SVN: r105729
This commit is contained in:
parent
972f427b1b
commit
ab940869ea
4 changed files with 48 additions and 17 deletions
|
@ -1,3 +1,15 @@
|
|||
2005-10-21 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
PR libstdc++/24450
|
||||
* config/locale/generic/time_members.h (__timepunct<>::
|
||||
__timepunct(__c_locale, const char*, size_t)): Avoid leaking
|
||||
memory if new throws inside _M_initialize_timepunct.
|
||||
* config/locale/gnu/time_members.h (__timepunct<>::
|
||||
__timepunct(__c_locale, const char*, size_t)): Likewise.
|
||||
* config/locale/gnu/message_members.h (messages<>::
|
||||
messages(__c_locale, const char*, size_t)): Rearrange to
|
||||
avoid memory leaks.
|
||||
|
||||
2005-10-19 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/ext/sso_string_base.h (_M_swap): Rewrite.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// std::time_get, std::time_put implementation, generic version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -55,10 +55,18 @@
|
|||
size_t __refs)
|
||||
: facet(__refs), _M_data(NULL)
|
||||
{
|
||||
char* __tmp = new char[std::strlen(__s) + 1];
|
||||
std::strcpy(__tmp, __s);
|
||||
const size_t __len = std::strlen(__s) + 1;
|
||||
char* __tmp = new char[__len];
|
||||
std::memcpy(__tmp, __s, __len);
|
||||
_M_name_timepunct = __tmp;
|
||||
_M_initialize_timepunct(__cloc);
|
||||
|
||||
try
|
||||
{ _M_initialize_timepunct(__cloc); }
|
||||
catch(...)
|
||||
{
|
||||
delete [] _M_name_timepunct;
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// std::messages implementation details, GNU version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -37,18 +37,21 @@
|
|||
template<typename _CharT>
|
||||
messages<_CharT>::messages(size_t __refs)
|
||||
: facet(__refs), _M_c_locale_messages(_S_get_c_locale()),
|
||||
_M_name_messages(_S_get_c_name())
|
||||
_M_name_messages(_S_get_c_name())
|
||||
{ }
|
||||
|
||||
template<typename _CharT>
|
||||
messages<_CharT>::messages(__c_locale __cloc, const char* __s,
|
||||
size_t __refs)
|
||||
: facet(__refs), _M_c_locale_messages(_S_clone_c_locale(__cloc)),
|
||||
_M_name_messages(__s)
|
||||
: facet(__refs), _M_c_locale_messages(NULL), _M_name_messages(NULL)
|
||||
{
|
||||
char* __tmp = new char[std::strlen(__s) + 1];
|
||||
std::strcpy(__tmp, __s);
|
||||
const size_t __len = std::strlen(__s) + 1;
|
||||
char* __tmp = new char[__len];
|
||||
std::memcpy(__tmp, __s, __len);
|
||||
_M_name_messages = __tmp;
|
||||
|
||||
// Last to avoid leaking memory if new throws.
|
||||
_M_c_locale_messages = _S_clone_c_locale(__cloc);
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// std::time_get, std::time_put implementation, GNU version -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -37,25 +37,33 @@
|
|||
template<typename _CharT>
|
||||
__timepunct<_CharT>::__timepunct(size_t __refs)
|
||||
: facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
|
||||
_M_name_timepunct(_S_get_c_name())
|
||||
_M_name_timepunct(_S_get_c_name())
|
||||
{ _M_initialize_timepunct(); }
|
||||
|
||||
template<typename _CharT>
|
||||
__timepunct<_CharT>::__timepunct(__cache_type* __cache, size_t __refs)
|
||||
: facet(__refs), _M_data(__cache), _M_c_locale_timepunct(NULL),
|
||||
_M_name_timepunct(_S_get_c_name())
|
||||
_M_name_timepunct(_S_get_c_name())
|
||||
{ _M_initialize_timepunct(); }
|
||||
|
||||
template<typename _CharT>
|
||||
__timepunct<_CharT>::__timepunct(__c_locale __cloc, const char* __s,
|
||||
size_t __refs)
|
||||
: facet(__refs), _M_data(NULL), _M_c_locale_timepunct(NULL),
|
||||
_M_name_timepunct(__s)
|
||||
_M_name_timepunct(NULL)
|
||||
{
|
||||
char* __tmp = new char[std::strlen(__s) + 1];
|
||||
std::strcpy(__tmp, __s);
|
||||
const size_t __len = std::strlen(__s) + 1;
|
||||
char* __tmp = new char[__len];
|
||||
std::memcpy(__tmp, __s, __len);
|
||||
_M_name_timepunct = __tmp;
|
||||
_M_initialize_timepunct(__cloc);
|
||||
|
||||
try
|
||||
{ _M_initialize_timepunct(__cloc); }
|
||||
catch(...)
|
||||
{
|
||||
delete [] _M_name_timepunct;
|
||||
__throw_exception_again;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename _CharT>
|
||||
|
|
Loading…
Add table
Reference in a new issue