Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
1ec83676
Kaydet (Commit)
1ec83676
authored
Nis 23, 2014
tarafından
Takeshi Abe
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoid possible memory leaks in case of exceptions
Change-Id: I047fd88a89900153089a55b6af123f11fb8bde55
üst
2ea006fb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
39 deletions
+27
-39
cppunittester.cxx
sal/cppunittester/cppunittester.cxx
+5
-5
tencinfo.cxx
sal/textenc/tencinfo.cxx
+9
-14
saxwriter.cxx
sax/source/expatwrap/saxwriter.cxx
+4
-3
xml2utf.cxx
sax/source/expatwrap/xml2utf.cxx
+9
-17
No files found.
sal/cppunittester/cppunittester.cxx
Dosyayı görüntüle @
1ec83676
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
#include "boost/noncopyable.hpp"
#include "boost/noncopyable.hpp"
#include "boost/ptr_container/ptr_vector.hpp"
#include "boost/ptr_container/ptr_vector.hpp"
#include <boost/scoped_array.hpp>
#include "boost/static_assert.hpp"
#include "boost/static_assert.hpp"
namespace
{
namespace
{
...
@@ -108,9 +109,9 @@ class EyecatcherListener
...
@@ -108,9 +109,9 @@ class EyecatcherListener
public
:
public
:
void
startTest
(
CppUnit
::
Test
*
test
)
SAL_OVERRIDE
void
startTest
(
CppUnit
::
Test
*
test
)
SAL_OVERRIDE
{
{
char
*
tn
=
new
char
[
test
->
getName
().
length
()
+
2
]
;
boost
::
scoped_array
<
char
>
tn
(
new
char
[
test
->
getName
().
length
()
+
2
])
;
strcpy
(
tn
,
test
->
getName
().
c_str
());
strcpy
(
tn
.
get
()
,
test
->
getName
().
c_str
());
int
len
=
strlen
(
tn
);
int
len
=
strlen
(
tn
.
get
()
);
for
(
int
i
=
0
;
i
<
len
;
i
++
)
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
{
if
(
!
isalnum
(
tn
[
i
]))
if
(
!
isalnum
(
tn
[
i
]))
...
@@ -120,8 +121,7 @@ public:
...
@@ -120,8 +121,7 @@ public:
}
}
tn
[
len
]
=
'_'
;
tn
[
len
]
=
'_'
;
tn
[
len
+
1
]
=
0
;
tn
[
len
+
1
]
=
0
;
setenv
(
"LO_TESTNAME"
,
tn
,
true
);
setenv
(
"LO_TESTNAME"
,
tn
.
get
(),
true
);
delete
[]
tn
;
}
}
void
endTest
(
CppUnit
::
Test
*
/* test */
)
SAL_OVERRIDE
void
endTest
(
CppUnit
::
Test
*
/* test */
)
SAL_OVERRIDE
...
...
sal/textenc/tencinfo.cxx
Dosyayı görüntüle @
1ec83676
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "gettextencodingdata.hxx"
#include "gettextencodingdata.hxx"
#include "tenchelp.hxx"
#include "tenchelp.hxx"
#include <boost/scoped_array.hpp>
sal_Bool
SAL_CALL
rtl_isOctetTextEncoding
(
rtl_TextEncoding
nEncoding
)
sal_Bool
SAL_CALL
rtl_isOctetTextEncoding
(
rtl_TextEncoding
nEncoding
)
{
{
...
@@ -407,20 +408,19 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixC
...
@@ -407,20 +408,19 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixC
};
};
rtl_TextEncoding
eEncoding
=
RTL_TEXTENCODING_DONTKNOW
;
rtl_TextEncoding
eEncoding
=
RTL_TEXTENCODING_DONTKNOW
;
char
*
pBuf
;
char
*
pTempBuf
;
char
*
pTempBuf
;
sal_uInt32
nBufLen
=
strlen
(
pUnixCharset
)
+
1
;
sal_uInt32
nBufLen
=
strlen
(
pUnixCharset
)
+
1
;
const
char
*
pFirstPart
;
const
char
*
pFirstPart
;
const
char
*
pSecondPart
;
const
char
*
pSecondPart
;
/* Alloc Buffer and map to lower case */
/* Alloc Buffer and map to lower case */
pBuf
=
new
char
[
nBufLen
]
;
boost
::
scoped_array
<
char
>
pBuf
(
new
char
[
nBufLen
])
;
Impl_toAsciiLower
(
pUnixCharset
,
pBuf
);
Impl_toAsciiLower
(
pUnixCharset
,
pBuf
.
get
()
);
/* Search FirstPart */
/* Search FirstPart */
pFirstPart
=
pBuf
;
pFirstPart
=
pBuf
.
get
()
;
pSecondPart
=
NULL
;
pSecondPart
=
NULL
;
pTempBuf
=
pBuf
;
pTempBuf
=
pBuf
.
get
()
;
while
(
*
pTempBuf
)
while
(
*
pTempBuf
)
{
{
if
(
*
pTempBuf
==
'-'
)
if
(
*
pTempBuf
==
'-'
)
...
@@ -463,8 +463,6 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixC
...
@@ -463,8 +463,6 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromUnixCharset( const char* pUnixC
}
}
}
}
delete
[]
pBuf
;
return
eEncoding
;
return
eEncoding
;
}
}
...
@@ -740,18 +738,17 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
...
@@ -740,18 +738,17 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
};
};
rtl_TextEncoding
eEncoding
=
RTL_TEXTENCODING_DONTKNOW
;
rtl_TextEncoding
eEncoding
=
RTL_TEXTENCODING_DONTKNOW
;
char
*
pBuf
;
const
ImplStrCharsetDef
*
pData
=
aVIPMimeCharsetTab
;
const
ImplStrCharsetDef
*
pData
=
aVIPMimeCharsetTab
;
sal_uInt32
nBufLen
=
strlen
(
pMimeCharset
)
+
1
;
sal_uInt32
nBufLen
=
strlen
(
pMimeCharset
)
+
1
;
/* Alloc Buffer and map to lower case and remove non alphanumeric chars */
/* Alloc Buffer and map to lower case and remove non alphanumeric chars */
pBuf
=
new
char
[
nBufLen
]
;
boost
::
scoped_array
<
char
>
pBuf
(
new
char
[
nBufLen
])
;
Impl_toAsciiLowerAndRemoveNonAlphanumeric
(
pMimeCharset
,
pBuf
);
Impl_toAsciiLowerAndRemoveNonAlphanumeric
(
pMimeCharset
,
pBuf
.
get
()
);
/* Search for equal in the VIP table */
/* Search for equal in the VIP table */
while
(
pData
->
mpCharsetStr
)
while
(
pData
->
mpCharsetStr
)
{
{
if
(
strcmp
(
pBuf
,
pData
->
mpCharsetStr
)
==
0
)
if
(
strcmp
(
pBuf
.
get
()
,
pData
->
mpCharsetStr
)
==
0
)
{
{
eEncoding
=
pData
->
meTextEncoding
;
eEncoding
=
pData
->
meTextEncoding
;
break
;
break
;
...
@@ -766,7 +763,7 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
...
@@ -766,7 +763,7 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
pData
=
aMimeCharsetTab
;
pData
=
aMimeCharsetTab
;
while
(
pData
->
mpCharsetStr
)
while
(
pData
->
mpCharsetStr
)
{
{
if
(
Impl_matchString
(
pBuf
,
pData
->
mpCharsetStr
)
)
if
(
Impl_matchString
(
pBuf
.
get
()
,
pData
->
mpCharsetStr
)
)
{
{
eEncoding
=
pData
->
meTextEncoding
;
eEncoding
=
pData
->
meTextEncoding
;
break
;
break
;
...
@@ -776,8 +773,6 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
...
@@ -776,8 +773,6 @@ rtl_TextEncoding SAL_CALL rtl_getTextEncodingFromMimeCharset( const char* pMimeC
}
}
}
}
delete
[]
pBuf
;
return
eEncoding
;
return
eEncoding
;
}
}
...
...
sax/source/expatwrap/saxwriter.cxx
Dosyayı görüntüle @
1ec83676
...
@@ -49,6 +49,7 @@ using namespace ::com::sun::star::util;
...
@@ -49,6 +49,7 @@ using namespace ::com::sun::star::util;
using
namespace
::
com
::
sun
::
star
::
io
;
using
namespace
::
com
::
sun
::
star
::
io
;
#include "xml2utf.hxx"
#include "xml2utf.hxx"
#include <boost/scoped_array.hpp>
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
uno
{
namespace
com
{
namespace
sun
{
namespace
star
{
namespace
uno
{
class
XComponentContext
;
class
XComponentContext
;
...
@@ -493,11 +494,11 @@ inline void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel) throw( SAXEx
...
@@ -493,11 +494,11 @@ inline void SaxWriterHelper::insertIndentation(sal_uInt32 m_nLevel) throw( SAXEx
else
else
{
{
sal_uInt32
nCount
(
m_nLevel
+
1
);
sal_uInt32
nCount
(
m_nLevel
+
1
);
sal_Int8
*
pBytes
=
new
sal_Int8
[
nCount
]
;
boost
::
scoped_array
<
sal_Int8
>
pBytes
(
new
sal_Int8
[
nCount
])
;
pBytes
[
0
]
=
LINEFEED
;
pBytes
[
0
]
=
LINEFEED
;
memset
(
&
(
pBytes
[
1
]),
32
,
m_nLevel
);
memset
(
&
(
pBytes
[
1
]),
32
,
m_nLevel
);
AddBytes
(
mp_Sequence
,
nCurrentPos
,
pBytes
,
nCount
);
AddBytes
(
mp_Sequence
,
nCurrentPos
,
pBytes
.
get
()
,
nCount
);
delete
[]
pBytes
;
pBytes
.
reset
()
;
nLastLineFeedPos
=
nCurrentPos
-
nCount
;
nLastLineFeedPos
=
nCurrentPos
-
nCount
;
if
(
nCurrentPos
==
SEQUENCESIZE
)
if
(
nCurrentPos
==
SEQUENCESIZE
)
nCurrentPos
=
writeSequence
();
nCurrentPos
=
writeSequence
();
...
...
sax/source/expatwrap/xml2utf.cxx
Dosyayı görüntüle @
1ec83676
...
@@ -32,6 +32,7 @@ using namespace ::com::sun::star::io;
...
@@ -32,6 +32,7 @@ using namespace ::com::sun::star::io;
#include "xml2utf.hxx"
#include "xml2utf.hxx"
#include <boost/scoped_array.hpp>
namespace
sax_expatwrap
{
namespace
sax_expatwrap
{
...
@@ -394,14 +395,14 @@ Sequence<sal_Unicode> Text2UnicodeConverter::convert( const Sequence<sal_Int8> &
...
@@ -394,14 +395,14 @@ Sequence<sal_Unicode> Text2UnicodeConverter::convert( const Sequence<sal_Int8> &
Sequence
<
sal_Unicode
>
seqUnicode
(
nSourceSize
);
Sequence
<
sal_Unicode
>
seqUnicode
(
nSourceSize
);
const
sal_Int8
*
pbSource
=
seqText
.
getConstArray
();
const
sal_Int8
*
pbSource
=
seqText
.
getConstArray
();
sal_Int8
*
pbTempMem
=
0
;
boost
::
scoped_array
<
sal_Int8
>
pbTempMem
;
if
(
m_seqSource
.
getLength
()
)
{
if
(
m_seqSource
.
getLength
()
)
{
// put old rest and new byte sequence into one array
// put old rest and new byte sequence into one array
pbTempMem
=
new
sal_Int8
[
nSourceSize
]
;
pbTempMem
.
reset
(
new
sal_Int8
[
nSourceSize
])
;
memcpy
(
pbTempMem
,
m_seqSource
.
getConstArray
()
,
m_seqSource
.
getLength
()
);
memcpy
(
pbTempMem
.
get
()
,
m_seqSource
.
getConstArray
()
,
m_seqSource
.
getLength
()
);
memcpy
(
&
(
pbTempMem
[
m_seqSource
.
getLength
()
])
,
seqText
.
getConstArray
()
,
seqText
.
getLength
()
);
memcpy
(
&
(
pbTempMem
[
m_seqSource
.
getLength
()
])
,
seqText
.
getConstArray
()
,
seqText
.
getLength
()
);
pbSource
=
pbTempMem
;
pbSource
=
pbTempMem
.
get
()
;
// set to zero again
// set to zero again
m_seqSource
=
Sequence
<
sal_Int8
>
();
m_seqSource
=
Sequence
<
sal_Int8
>
();
...
@@ -436,11 +437,6 @@ Sequence<sal_Unicode> Text2UnicodeConverter::convert( const Sequence<sal_Int8> &
...
@@ -436,11 +437,6 @@ Sequence<sal_Unicode> Text2UnicodeConverter::convert( const Sequence<sal_Int8> &
memcpy
(
m_seqSource
.
getArray
()
,
&
(
pbSource
[
nSourceCount
])
,
nSourceSize
-
nSourceCount
);
memcpy
(
m_seqSource
.
getArray
()
,
&
(
pbSource
[
nSourceCount
])
,
nSourceSize
-
nSourceCount
);
}
}
if
(
pbTempMem
)
{
delete
[]
pbTempMem
;
}
// set to correct unicode size
// set to correct unicode size
seqUnicode
.
realloc
(
nTargetCount
);
seqUnicode
.
realloc
(
nTargetCount
);
...
@@ -471,7 +467,7 @@ Unicode2TextConverter::~Unicode2TextConverter()
...
@@ -471,7 +467,7 @@ Unicode2TextConverter::~Unicode2TextConverter()
Sequence
<
sal_Int8
>
Unicode2TextConverter
::
convert
(
const
sal_Unicode
*
puSource
,
sal_Int32
nSourceSize
)
Sequence
<
sal_Int8
>
Unicode2TextConverter
::
convert
(
const
sal_Unicode
*
puSource
,
sal_Int32
nSourceSize
)
{
{
sal_Unicode
*
puTempMem
=
0
;
boost
::
scoped_array
<
sal_Unicode
>
puTempMem
;
if
(
m_seqSource
.
getLength
()
)
{
if
(
m_seqSource
.
getLength
()
)
{
// For surrogates !
// For surrogates !
...
@@ -479,15 +475,15 @@ Sequence<sal_Int8> Unicode2TextConverter::convert(const sal_Unicode *puSource ,
...
@@ -479,15 +475,15 @@ Sequence<sal_Int8> Unicode2TextConverter::convert(const sal_Unicode *puSource ,
// In general when surrogates are used, they should be rarely
// In general when surrogates are used, they should be rarely
// cut off between two convert()-calls. So this code is used
// cut off between two convert()-calls. So this code is used
// rarely and the extra copy is acceptable.
// rarely and the extra copy is acceptable.
puTempMem
=
new
sal_Unicode
[
nSourceSize
+
m_seqSource
.
getLength
()]
;
puTempMem
.
reset
(
new
sal_Unicode
[
nSourceSize
+
m_seqSource
.
getLength
()])
;
memcpy
(
puTempMem
,
memcpy
(
puTempMem
.
get
()
,
m_seqSource
.
getConstArray
()
,
m_seqSource
.
getConstArray
()
,
m_seqSource
.
getLength
()
*
sizeof
(
sal_Unicode
)
);
m_seqSource
.
getLength
()
*
sizeof
(
sal_Unicode
)
);
memcpy
(
memcpy
(
&
(
puTempMem
[
m_seqSource
.
getLength
()
])
,
&
(
puTempMem
[
m_seqSource
.
getLength
()
])
,
puSource
,
puSource
,
nSourceSize
*
sizeof
(
sal_Unicode
)
);
nSourceSize
*
sizeof
(
sal_Unicode
)
);
puSource
=
puTempMem
;
puSource
=
puTempMem
.
get
()
;
nSourceSize
+=
m_seqSource
.
getLength
();
nSourceSize
+=
m_seqSource
.
getLength
();
m_seqSource
=
Sequence
<
sal_Unicode
>
();
m_seqSource
=
Sequence
<
sal_Unicode
>
();
...
@@ -539,10 +535,6 @@ Sequence<sal_Int8> Unicode2TextConverter::convert(const sal_Unicode *puSource ,
...
@@ -539,10 +535,6 @@ Sequence<sal_Int8> Unicode2TextConverter::convert(const sal_Unicode *puSource ,
(
nSourceSize
-
nSourceCount
)
*
sizeof
(
sal_Unicode
)
);
(
nSourceSize
-
nSourceCount
)
*
sizeof
(
sal_Unicode
)
);
}
}
if
(
puTempMem
)
{
delete
[]
puTempMem
;
}
// reduce the size of the buffer (fast, no copy necessary)
// reduce the size of the buffer (fast, no copy necessary)
seqText
.
realloc
(
nTargetCount
);
seqText
.
realloc
(
nTargetCount
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment