Skip to content

Commit

Permalink
BAGEL: Fix memory leaks. PVS-Studio V773
Browse files Browse the repository at this point in the history
  • Loading branch information
sluicebox committed May 8, 2024
1 parent ca2528a commit 97f9e48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions engines/bagel/baglib/character_object.cpp
Expand Up @@ -74,6 +74,7 @@ ErrorCode CBagCharacterObject::attach() {
decoder->setSoundType(Audio::Mixer::kSFXSoundType);
if (!decoder->loadFile(filename.getBuffer())) {
logError(buildString("CHAR SmackOpen failed: %s ", filename.getBuffer()));
delete decoder;
return ERR_FOPEN;
}

Expand Down
7 changes: 3 additions & 4 deletions engines/bagel/spacebar/sraf_computer.cpp
Expand Up @@ -4558,12 +4558,11 @@ SrafTextScreen::SrafTextScreen(const CBofString &str, bool isText) :
_text = str;

} else {
CBofFile *file = new CBofFile(str, CBF_BINARY | CBF_READONLY);
assert(file != nullptr);
CBofFile file(str, CBF_BINARY | CBF_READONLY);

size_t len = file->getLength();
size_t len = file.getLength();
char *tmp = new char[len + 1];
file->read(tmp, len);
file.read(tmp, len);
tmp[len] = '\0';

_text = CBofString(tmp);
Expand Down

0 comments on commit 97f9e48

Please sign in to comment.