[Scummvm-git-logs] scummvm master -> 5bf1cc00ff4cd2ec5207d7b73986177b723a73d6

rvanlaar noreply at scummvm.org
Tue Sep 27 08:00:31 UTC 2022


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5bf1cc00ff VIDEO: PACo decoder: Fix coverity issues


Commit: 5bf1cc00ff4cd2ec5207d7b73986177b723a73d6
    https://github.com/scummvm/scummvm/commit/5bf1cc00ff4cd2ec5207d7b73986177b723a73d6
Author: Roland van Laar (roland at rolandvanlaar.nl)
Date: 2022-09-27T09:57:57+02:00

Commit Message:
VIDEO: PACo decoder: Fix coverity issues

Remove unused integer _frameDelay:
    Fixes COVERITY: 1476344
Initialize Non-static class members on PacoDecoder:
    Fixes COVERITY: 1476353
Resource leak in object No destructor on PacoAudioTrack:
    Fixes COVERITY: 1476360

Fix memory leak in handleFrame. Delete copied data in fdata.

Changed paths:
    video/paco_decoder.cpp
    video/paco_decoder.h


diff --git a/video/paco_decoder.cpp b/video/paco_decoder.cpp
index c5d78ba0e45..4e40e1ee5e8 100644
--- a/video/paco_decoder.cpp
+++ b/video/paco_decoder.cpp
@@ -49,13 +49,23 @@ enum frameTypes {
 	EOC = 11 // - end of chunk marker
 };
 
-PacoDecoder::PacoDecoder() {
+PacoDecoder::PacoDecoder()
+	: _fileStream(nullptr), _videoTrack(nullptr), _audioTrack(nullptr) {
 }
 
 PacoDecoder::~PacoDecoder() {
 	close();
 }
 
+void PacoDecoder::PacoDecoder::close() {
+	Video::VideoDecoder::close();
+
+	delete _fileStream;
+	_fileStream = nullptr;
+	_videoTrack = nullptr;
+	_audioTrack = nullptr;
+}
+
 bool PacoDecoder::loadStream(Common::SeekableReadStream *stream) {
 	close();
 
@@ -549,6 +559,7 @@ void PacoDecoder::PacoVideoTrack::handleFrame(Common::SeekableReadStream *fileSt
 
 	_dirtyRects.clear();
 	_dirtyRects.push_back(Common::Rect(x, y, x + bw, y + bh));
+	delete[] fdata;
 }
 
 void PacoDecoder::PacoVideoTrack::copyDirtyRectsToBuffer(uint8 *dst, uint pitch) {
@@ -568,6 +579,10 @@ PacoDecoder::PacoAudioTrack::PacoAudioTrack(int samplingRate)
 	_packetStream = Audio::makePacketizedRawStream(samplingRate, audioFlags);
 }
 
+PacoDecoder::PacoAudioTrack::~PacoAudioTrack() {
+	delete _packetStream;
+}
+
 void PacoDecoder::PacoAudioTrack::queueSound(Common::SeekableReadStream *fileStream, uint32 chunkSize) {
 	const Common::Array<int> samplingRates = {5563, 7418, 11127, 22254};
 	uint16 header = fileStream->readUint16BE();
diff --git a/video/paco_decoder.h b/video/paco_decoder.h
index 9dbdd7af5f5..67cff6d0d7a 100644
--- a/video/paco_decoder.h
+++ b/video/paco_decoder.h
@@ -48,6 +48,7 @@ class PacoDecoder : public VideoDecoder {
 public:
 	PacoDecoder();
 	virtual ~PacoDecoder();
+	void close() override;
 
 	virtual bool loadStream(Common::SeekableReadStream *stream) override;
 
@@ -93,7 +94,6 @@ protected:
 
 		int _curFrame;
 		uint32 _frameCount;
-		uint32 _frameDelay;
 		uint16 _frameRate;
 
 		Common::List<Common::Rect> _dirtyRects;
@@ -102,6 +102,7 @@ protected:
 	class PacoAudioTrack : public AudioTrack {
 	public:
 		PacoAudioTrack(int samplingRate);
+		~PacoAudioTrack();
 		void queueSound(Common::SeekableReadStream *fileStream, uint32 chunkSize);
 
 	protected:




More information about the Scummvm-git-logs mailing list