[Scummvm-git-logs] scummvm master -> 30661a9f07bb17057a5a5db32a9ec9b2e06c32f1

bluegr noreply at scummvm.org
Thu Dec 19 20:51:23 UTC 2024


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

Summary:
b792ba090d GRAPHICS: Handle seek-only case in TTFLibrary readCallback
30661a9f07 COMMON: Avoid passing nullptr to memcpy in MemoryReadStream read()


Commit: b792ba090dfa045212ed278e5401fd24b6cbf30e
    https://github.com/scummvm/scummvm/commit/b792ba090dfa045212ed278e5401fd24b6cbf30e
Author: tunnelsociety (150493071+tunnelsociety at users.noreply.github.com)
Date: 2024-12-19T22:51:20+02:00

Commit Message:
GRAPHICS: Handle seek-only case in TTFLibrary readCallback

As documented in FreeType API Reference. This avoids passing
a null buffer to ttfFile->read().

Changed paths:
    graphics/fonts/ttf.cpp


diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index 2eed481b29c..9b8fb60548e 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -149,7 +149,10 @@ void TTFLibrary::closeFont(FT_Face &face) {
 
 unsigned long TTFLibrary::readCallback(FT_Stream stream, unsigned long offset, unsigned char *buffer, unsigned long count) {
 	Common::SeekableReadStream *ttfFile = (Common::SeekableReadStream *)stream->descriptor.pointer;
-	ttfFile->seek(offset);
+	bool seekSuccess = ttfFile->seek(offset);
+	if (count == 0)
+		// a seek operation was requested: return zero if success else non-zero
+		return !seekSuccess;
 	return ttfFile->read(buffer, count);
 }
 


Commit: 30661a9f07bb17057a5a5db32a9ec9b2e06c32f1
    https://github.com/scummvm/scummvm/commit/30661a9f07bb17057a5a5db32a9ec9b2e06c32f1
Author: tunnelsociety (150493071+tunnelsociety at users.noreply.github.com)
Date: 2024-12-19T22:51:20+02:00

Commit Message:
COMMON: Avoid passing nullptr to memcpy in MemoryReadStream read()

Even with dataSize=0, this is undefined behaviour.
What caller would pass in nullptr? UBSan caught this happening in a
FreeType callback, for example.

Changed paths:
    common/stream.cpp


diff --git a/common/stream.cpp b/common/stream.cpp
index e408fbe7057..59aa36dbee6 100644
--- a/common/stream.cpp
+++ b/common/stream.cpp
@@ -111,6 +111,9 @@ Common::String ReadStream::readPascalString(bool transformCR) {
 }
 
 uint32 MemoryReadStream::read(void *dataPtr, uint32 dataSize) {
+	if(dataPtr == nullptr)
+		return 0;
+
 	// Read at most as many bytes as are still available...
 	if (dataSize > _size - _pos) {
 		dataSize = _size - _pos;




More information about the Scummvm-git-logs mailing list