Remove finding from code analysis.

pull/591/merge
Kim Kulling 2015-06-28 21:06:20 +02:00
parent 6249a1c06f
commit db3aea4b18
3 changed files with 23 additions and 13 deletions

View File

@ -49,11 +49,11 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ASSIMP_BUILD_NO_3DS_IMPORTER #ifndef ASSIMP_BUILD_NO_3DS_IMPORTER
// internal headers // internal headers
#include "3DSLoader.h" #include "3DSLoader.h"
#include "Macros.h" #include "Macros.h"
#include "../include/assimp/IOSystem.hpp" #include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/scene.h" #include "../include/assimp/scene.h"
#include "../include/assimp/DefaultLogger.hpp" #include "../include/assimp/DefaultLogger.hpp"
#include "StringComparison.h" #include "StringComparison.h"
using namespace Assimp; using namespace Assimp;

View File

@ -239,8 +239,10 @@ unsigned B3DImporter::ChunkSize(){
template<class T> template<class T>
T *B3DImporter::to_array( const vector<T> &v ){ T *B3DImporter::to_array( const vector<T> &v ){
if( !v.size() ) return 0; if( v.empty() ) {
T *p=new T[v.size()]; return 0;
}
T *p=new T[ v.size() ];
for( size_t i=0;i<v.size();++i ){ for( size_t i=0;i<v.size();++i ){
p[i]=v[i]; p[i]=v[i];
} }

View File

@ -154,20 +154,26 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
// read 200 characters from the file // read 200 characters from the file
boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]); boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]);
char* buffer = _buffer.get(); char* buffer = _buffer.get();
if( NULL == buffer ) {
return false;
}
const size_t read = pStream->Read(buffer,1,searchBytes); const size_t read = pStream->Read(buffer,1,searchBytes);
if (!read) if( !read ) {
return false; return false;
}
for (size_t i = 0; i < read; ++i) for( size_t i = 0; i < read; ++i ) {
buffer[i] = ::tolower(buffer[i]); buffer[ i ] = ::tolower( buffer[ i ] );
}
// It is not a proper handling of unicode files here ... // It is not a proper handling of unicode files here ...
// ehm ... but it works in most cases. // ehm ... but it works in most cases.
char* cur = buffer,*cur2 = buffer,*end = &buffer[read]; char* cur = buffer,*cur2 = buffer,*end = &buffer[read];
while (cur != end) { while (cur != end) {
if (*cur) if( *cur ) {
*cur2++ = *cur; *cur2++ = *cur;
}
++cur; ++cur;
} }
*cur2 = '\0'; *cur2 = '\0';
@ -177,8 +183,9 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
const char* r = strstr(buffer,tokens[i]); const char* r = strstr(buffer,tokens[i]);
if (!r) if( !r ) {
continue; continue;
}
// We got a match, either we don't care where it is, or it happens to // We got a match, either we don't care where it is, or it happens to
// be in the beginning of the file / line // be in the beginning of the file / line
if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') { if (!tokensSol || r == buffer || r[-1] == '\r' || r[-1] == '\n') {
@ -187,6 +194,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
} }
} }
} }
return false; return false;
} }