[Scummvm-git-logs] scummvm master -> f1d9955540076e044905afb3fd6dbc03034aacd3

csnover csnover at users.noreply.github.com
Wed Feb 8 19:06:04 CET 2017


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:
f1d9955540 COMMON: Fix calling Span::getStringAt with non-zero index


Commit: f1d9955540076e044905afb3fd6dbc03034aacd3
    https://github.com/scummvm/scummvm/commit/f1d9955540076e044905afb3fd6dbc03034aacd3
Author: Colin Snover (github.com at zetafleet.com)
Date: 2017-02-08T12:05:14-06:00

Commit Message:
COMMON: Fix calling Span::getStringAt with non-zero index

Changed paths:
    common/span.h
    test/common/span.h


diff --git a/common/span.h b/common/span.h
index 0bb5a25..2acc0b5 100644
--- a/common/span.h
+++ b/common/span.h
@@ -393,14 +393,14 @@ public:
 
 	inline String getStringAt(const index_type index, size_type numEntries = kSpanMaxSize) const {
 		STATIC_ASSERT(sizeof(value_type) == sizeof(char), strings_can_only_be_read_from_byte_or_char_spans);
-		const char *string = (const char *)impl().data();
+		const char *string = (const char *)impl().data() + index;
 
 		if (numEntries == kSpanMaxSize) {
 			numEntries = strnlen(string, impl().size() - index);
 		}
 
 		impl().validate(index, numEntries);
-		return String(string + index, numEntries);
+		return String(string, numEntries);
 	}
 
 	/**
diff --git a/test/common/span.h b/test/common/span.h
index d9b1d31..55ef2c6 100644
--- a/test/common/span.h
+++ b/test/common/span.h
@@ -496,6 +496,8 @@ public:
 
 		TS_ASSERT(span.getStringAt(0) == data);
 		TS_ASSERT(span.getStringAt(0, 2) == "he");
+		TS_ASSERT(span.getStringAt(2) == "llo");
+		TS_ASSERT(span.getStringAt(2, 3) == "llo");
 		span[3] = '\0';
 		TS_ASSERT(span.getStringAt(0) == "hel");
 	}





More information about the Scummvm-git-logs mailing list