Browse Source

Fix some legitimate bugs found by Coverity which MAY IMPACT BEHAVIOR!

Michael Hansen 10 years ago
parent
commit
93eb41b1fe
  1. 4
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp
  2. 6
      Sources/Plasma/NucleusLib/inc/plProfileManager.cpp
  3. 4
      Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp
  4. 11
      Sources/Plasma/PubUtilLib/plAudio/plDSoundBuffer.cpp
  5. 2
      Sources/Plasma/PubUtilLib/plDrawable/plSpanInstance.h
  6. 4
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp
  7. 6
      Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h
  8. 1
      Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp
  9. 2
      Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp
  10. 2
      Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp
  11. 2
      Sources/Tools/MaxConvert/plLightMapGen.cpp
  12. 2
      Sources/Tools/MaxExport/plExportDlg.cpp
  13. 4
      Sources/Tools/MaxMain/plComponentDlg.cpp

4
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCmd.cpp

@ -428,8 +428,8 @@ void pfConsoleCmd::ICreateSignature(const char *paramList )
hsAssert( strlen( paramList ) < sizeof( params ), "Make the (#*$& params string larger!" );
hsStrcpy( params, paramList );
fSignature.Empty();
fSigLabels.Empty();
fSignature.Reset();
fSigLabels.Reset();
/// Loop through all the types given in the list
ptr = params;

6
Sources/Plasma/NucleusLib/inc/plProfileManager.cpp

@ -237,12 +237,12 @@ void plProfileBase::IPrintValue(uint64_t value, char* buf, bool printType)
if (value > (1024*1000))
sprintf(buf, "%.2f MB", float(value) / (1024.f * 1024.f));
else if (value > 1024)
sprintf(buf, "%d KB", value / 1024);
sprintf(buf, "%llu KB", value / 1024);
else
sprintf(buf, "%d b", value);
sprintf(buf, "%llu b", value);
}
else
sprintf(buf, "%u", value);
sprintf(buf, "%llu", value);
}
}

4
Sources/Plasma/NucleusLib/pnMessage/plNotifyMsg.cpp

@ -147,6 +147,7 @@ void plNotifyMsg::AddEvent( proEventData* ed )
proCoopEventData *evt = (proCoopEventData *)ed;
AddCoopEvent( evt->fID, evt->fSerial);
}
break;
case proEventData::kControlKey:
{
@ -200,16 +201,19 @@ void plNotifyMsg::AddEvent( proEventData* ed )
proOfferLinkingBookEventData* evt = (proOfferLinkingBookEventData*)ed;
AddOfferBookEvent(evt->offerer, evt->targetAge, evt->offeree);
}
break;
case proEventData::kBook:
{
proBookEventData* evt = (proBookEventData*)ed;
AddBookEvent( evt->fEvent, evt->fLinkID );
}
break;
case proEventData::kClimbingBlockerHit:
{
proClimbingBlockerHitEventData* evt = (proClimbingBlockerHitEventData*)ed;
AddHitClimbingBlockerEvent(evt->fBlockerKey);
}
break;
}
}

11
Sources/Plasma/PubUtilLib/plAudio/plDSoundBuffer.cpp

@ -283,7 +283,7 @@ bool plDSoundBuffer::SetupStreamingSource(plAudioFileReader *stream)
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048);
alGetError();
error = alGetError();
if( error != AL_NO_ERROR )
{
return false;
@ -348,7 +348,7 @@ bool plDSoundBuffer::SetupStreamingSource(void *data, unsigned bytes)
SetScalarVolume(0);
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048);
alGetError();
error = alGetError();
if( error != AL_NO_ERROR )
{
return false;
@ -478,8 +478,7 @@ bool plDSoundBuffer::GetAvailableBufferId(unsigned *bufferId)
bool plDSoundBuffer::SetupVoiceSource()
{
ALenum error;
alGetError();
ALenum error = alGetError();
// Generate AL Buffers
alGenBuffers( STREAMING_BUFFERS, streamingBuffers );
@ -507,13 +506,13 @@ bool plDSoundBuffer::SetupVoiceSource()
SetScalarVolume(0);
alSourcef(source, AL_ROLLOFF_FACTOR, 0.3048);
alGetError();
error = alGetError();
if( error != AL_NO_ERROR )
{
return false;
}
alSourcei(source, AL_BUFFER, 0);
alGetError();
error = alGetError();
//alSourcei(source, AL_PITCH, 0);
// dont queue any buffers here

2
Sources/Plasma/PubUtilLib/plDrawable/plSpanInstance.h

@ -171,7 +171,7 @@ public:
}
static uint16_t ColStrideFromEncoding(const plSpanEncoding& encoding)
{
switch(encoding.fCode & plSpanEncoding::kPosMask)
switch(encoding.fCode & plSpanEncoding::kColMask)
{
case plSpanEncoding::kColNone:
return 0;

4
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.cpp

@ -331,14 +331,14 @@ void plDynamicTextMap::SetInitBuffer( uint32_t *buffer )
//// CopyFrom /////////////////////////////////////////////////////////////////
void plDynamicTextMap::CopyFrom( plMipmap *source )
void plDynamicTextMap::CopyFrom(const plMipmap *source)
{
hsAssert( false, "Copying plDynamicTextMaps is not supported." );
}
//// Clone ////////////////////////////////////////////////////////////////////
plMipmap *plDynamicTextMap::Clone( void )
plMipmap *plDynamicTextMap::Clone() const
{
static bool alreadyWarned = false;

6
Sources/Plasma/PubUtilLib/plGImage/plDynamicTextMap.h

@ -130,9 +130,9 @@ class plDynamicTextMap : public plMipmap
virtual uint8_t GetNumLevels( void ) const { return 1; }
virtual void Colorize( void ) { ; }
virtual plMipmap *Clone( void );
virtual void CopyFrom( plMipmap *source );
void Colorize() override { }
plMipmap *Clone() const override;
void CopyFrom(const plMipmap *source) override;
/// Operations to perform on the text block

1
Sources/Plasma/PubUtilLib/plInputCore/plAvatarInputInterface.cpp

@ -471,6 +471,7 @@ bool plAvatarInputInterface::IHandleCtrlCmd( plCtrlCmd *cmd )
fCurrentCursor = kCursorHidden;
else
fCurrentCursor = kCursorUp;
return true;
case S_SET_LADDER_CONTROL:
if( cmd->fControlActivated )
ISetLadderMap();

2
Sources/Plasma/PubUtilLib/plSDL/plStateDataRecord.cpp

@ -838,7 +838,7 @@ void plStateDataRecord::TimeStampDirtyVars()
// set nested vars
for(i=0;i<fSDVarsList.size(); i++)
{
if ( fVarsList[i]->IsDirty() )
if ( fSDVarsList[i]->IsDirty() )
fSDVarsList[i]->TimeStamp();
}
}

2
Sources/Plasma/PubUtilLib/plSDL/plStateVariable.cpp

@ -839,6 +839,7 @@ bool plSimpleStateVariable::IConvertFromShort(plVarDescriptor::Type newType)
delete [] fS;
fI = newI;
}
break;
case plVarDescriptor::kByte:
{
uint8_t* newBy = new uint8_t[fVar.GetCount()];
@ -897,6 +898,7 @@ bool plSimpleStateVariable::IConvertFromByte(plVarDescriptor::Type newType)
delete [] fBy;
fI = newI;
}
break;
case plVarDescriptor::kShort:
{
short* newS = new short[fVar.GetCount()];

2
Sources/Tools/MaxConvert/plLightMapGen.cpp

@ -1587,7 +1587,7 @@ bool plLightMapGen::ISelectBitmapDimension(plMaxNode* node, const hsMatrix44& l2
if( dvDr > 0 )
{
fHeight = (int)(kTexPerFoot / duDr);
fHeight = (int)(kTexPerFoot / dvDr);
if( fHeight > kMaxSize )
fHeight = kMaxSize;

2
Sources/Tools/MaxExport/plExportDlg.cpp

@ -489,7 +489,7 @@ void plExportDlgImp::StartAutoExport()
char outputDir[MAX_PATH];
GetPrivateProfileString("Settings", "MaxOutputDir", "", outputDir, sizeof(outputDir), configFile);
if (inputDir[0] == '\0' || outputDir == '\0')
if (inputDir[0] == '\0' || outputDir[0] == '\0')
return;
fAutoExporting = true;

4
Sources/Tools/MaxMain/plComponentDlg.cpp

@ -174,8 +174,8 @@ void plComponentDlg::IPositionControl(HWND hControl, int hDiff, int wDiff, int f
RECT rect;
GetWindowRect(hControl, &rect);
hsAssert(!((flags & kMoveX) & (flags & kResizeX)), "Moving AND resizing in X in IPositionControl");
hsAssert(!((flags & kMoveY) & (flags & kResizeY)), "Moving AND resizing in Y in IPositionControl");
hsAssert(!((flags & kMoveX) && (flags & kResizeX)), "Moving AND resizing in X in IPositionControl");
hsAssert(!((flags & kMoveY) && (flags & kResizeY)), "Moving AND resizing in Y in IPositionControl");
if (flags & kMoveX || flags & kMoveY)
{

Loading…
Cancel
Save