mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Fix some crashes (issue #1076)
This commit is contained in:
parent
6d46fd1529
commit
04d9dc43f6
3
bgl.cc
3
bgl.cc
|
@ -289,11 +289,14 @@ namespace
|
|||
|
||||
size_t len = idx.read< uint32_t >();
|
||||
|
||||
if( len )
|
||||
{
|
||||
vector< char > nameBuf( len );
|
||||
|
||||
idx.read( &nameBuf.front(), len );
|
||||
|
||||
dictionaryName = string( &nameBuf.front(), len );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
|
@ -161,8 +161,11 @@ DictdDictionary::DictdDictionary( string const & id,
|
|||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if( dName.size() > 0 )
|
||||
{
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Open the .dict file
|
||||
|
||||
|
|
6
dsl.cc
6
dsl.cc
|
@ -310,12 +310,18 @@ DslDictionary::DslDictionary( string const & id,
|
|||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if( dName.size() > 0 )
|
||||
{
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
vector< char > sName( idx.read< uint32_t >() );
|
||||
if( sName.size() > 0 )
|
||||
{
|
||||
idx.read( &sName.front(), sName.size() );
|
||||
preferredSoundDictionary = string( &sName.front(), sName.size() );
|
||||
}
|
||||
|
||||
// Everything else would be done in deferred init
|
||||
}
|
||||
|
|
|
@ -204,8 +204,11 @@ EpwingDictionary::EpwingDictionary( string const & id,
|
|||
{
|
||||
vector< char > data( idxHeader.nameSize );
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
if( data.size() > 0 )
|
||||
{
|
||||
idx.read( &data.front(), idxHeader.nameSize );
|
||||
bookName = string( &data.front(), idxHeader.nameSize );
|
||||
}
|
||||
|
||||
// Initialize eBook
|
||||
|
||||
|
|
3
gls.cc
3
gls.cc
|
@ -549,8 +549,11 @@ GlsDictionary::GlsDictionary( string const & id,
|
|||
idx.seek( sizeof( idxHeader ) );
|
||||
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if( dName.size() > 0 )
|
||||
{
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
6
mdx.cc
6
mdx.cc
|
@ -303,14 +303,20 @@ MdxDictionary::MdxDictionary( string const & id, string const & indexFile,
|
|||
idx.seek( sizeof( idxHeader ) );
|
||||
size_t len = idx.read< uint32_t >();
|
||||
vector< char > buf( len );
|
||||
if( len > 0 )
|
||||
{
|
||||
idx.read( &buf.front(), len );
|
||||
dictionaryName = string( &buf.front(), len );
|
||||
}
|
||||
|
||||
// then read the dictionary's encoding
|
||||
len = idx.read< uint32_t >();
|
||||
if( len > 0 )
|
||||
{
|
||||
buf.resize( len );
|
||||
idx.read( &buf.front(), len );
|
||||
encoding = string( &buf.front(), len );
|
||||
}
|
||||
|
||||
dictFile.setFileName( QString::fromUtf8( dictionaryFiles[ 0 ].c_str() ) );
|
||||
dictFile.open( QIODevice::ReadOnly );
|
||||
|
|
3
sdict.cc
3
sdict.cc
|
@ -212,8 +212,11 @@ SdictDictionary::SdictDictionary( string const & id,
|
|||
|
||||
idx.seek( sizeof( idxHeader ) );
|
||||
vector< char > dName( idx.read< uint32_t >() );
|
||||
if( dName.size() > 0 )
|
||||
{
|
||||
idx.read( &dName.front(), dName.size() );
|
||||
dictionaryName = string( &dName.front(), dName.size() );
|
||||
}
|
||||
|
||||
// Initialize the index
|
||||
|
||||
|
|
|
@ -312,6 +312,9 @@ void StardictDictionary::loadIcon() throw()
|
|||
|
||||
string StardictDictionary::loadString( size_t size )
|
||||
{
|
||||
if( size == 0 )
|
||||
return string();
|
||||
|
||||
vector< char > data( size );
|
||||
|
||||
idx.read( &data.front(), data.size() );
|
||||
|
|
Loading…
Reference in a new issue