Index: src/ch/charvect.h =================================================================== diff -u -rcdf6a22ddf857f56ce2e27e26d8cd6f0b8034b2e -rd2b121c78f510b5384b8ef0ca80afbfd7f77fef7 --- src/ch/charvect.h (.../charvect.h) (revision cdf6a22ddf857f56ce2e27e26d8cd6f0b8034b2e) +++ src/ch/charvect.h (.../charvect.h) (revision d2b121c78f510b5384b8ef0ca80afbfd7f77fef7) @@ -1,22 +1,21 @@ -/************************************************************************ - Copy Handler 1.x - program for copying data in Microsoft Windows - systems. - Copyright (C) 2001-2003 Ixen Gerthannes (ixen@interia.pl) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*************************************************************************/ +/*************************************************************************** +* Copyright (C) 2001-2008 by J�zef Starosczyk * +* ixen@copyhandler.com * +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU Library General Public License * +* (version 2) as published by the Free Software Foundation; * +* * +* This program is distributed in the hope that it will be useful, * +* but WITHOUT ANY WARRANTY; without even the implied warranty of * +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * +* GNU General Public License for more details. * +* * +* You should have received a copy of the GNU Library General Public * +* License along with this program; if not, write to the * +* Free Software Foundation, Inc., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ #ifndef __CHARVECT_H__ #define __CHARVECT_H__ @@ -63,13 +62,21 @@ { size_type _Size=_tcslen(_Val)+1; PTSTR *ppsz=new PTSTR[_Count]; - for (size_type i=0;i<_Count;i++) + try { - ppsz[i]=new TCHAR[_Size]; - _tcscpy(ppsz[i], _Val); - } + for (size_type i=0;i<_Count;i++) + { + ppsz[i]=new TCHAR[_Size]; + _tcscpy(ppsz[i], _Val); + } - ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); + ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); + } + catch(...) + { + delete [] ppsz; + throw; + } delete [] ppsz; } else @@ -79,30 +86,44 @@ { size_type _Size=_tcslen(_Val)+1; PTSTR *ppsz=new PTSTR[_Count]; - for(size_type i=0;i<_Count;i++) + try { - ppsz[i]=new TCHAR[_Size]; - _tcscpy(ppsz[i], _Val); - } + for(size_type i=0;i<_Count;i++) + { + ppsz[i]=new TCHAR[_Size]; + _tcscpy(ppsz[i], _Val); + } - ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); - delete [] ppsz; + ((vector*)this)->insert(_Where, ppsz, ppsz+_Count); + } + catch(...) + { + delete [] ppsz; + } }; template void insert(iterator _Where, _It _First, _It _Last, bool bCopy) { if (bCopy) { size_type _Cnt=_Last-_First; PTSTR *ppsz=new PTSTR[_Cnt]; - for (size_type i=0;i<_Cnt;i++) + try { - ppsz[i]=new TCHAR[_tcslen(*_First)+1]; - _tcscpy(ppsz[i], *_First); + for (size_type i=0;i<_Cnt;i++) + { + ppsz[i]=new TCHAR[_tcslen(*_First)+1]; + _tcscpy(ppsz[i], *_First); - _First++; - } + _First++; + } - ((vector*)this)->insert(_Where, ppsz, ppsz+_Cnt); + ((vector*)this)->insert(_Where, ppsz, ppsz+_Cnt); + } + catch(...) + { + delete [] ppsz; + throw; + } delete [] ppsz; } else