Skip to content

Commit

Permalink
fix RangeError for some images
Browse files Browse the repository at this point in the history
make_string_uc causes RangeError for incorrect input seq.

Fixes #7
  • Loading branch information
bigflood committed Jan 19, 2019
1 parent 178368b commit 7678d5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/src/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ String make_string(List<int> seq) {
// Special version to deal with the code in the first 8 bytes of a user comment.
// First 8 bytes gives coding system e.g. ASCII vs. JIS vs Unicode.
String make_string_uc(List<int> seq) {
if (seq.length <= 8) {
return "";
}
seq = seq.sublist(8);
// Of course, this is only correct if ASCII, and the standard explicitly
// allows JIS and Unicode.
Expand Down
13 changes: 13 additions & 0 deletions test/util_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import "package:test/test.dart";
import 'package:exif/src/util.dart';

void main() {
test("make_string_uc", () {
expect(make_string_uc([]), equals(""));
expect(make_string_uc([1,2,3,4,5,6,7]), equals(""));
expect(make_string_uc([1,2,3,4,5,6,7,8,9,10]), equals("[9, 10]"));
expect(make_string_uc([1,2,3,4,5,6,7,8,9,10]), equals("[9, 10]"));
expect(make_string_uc([1,2,3,4,5,6,7,8,97,98,99]), equals("abc"));
});
}

0 comments on commit 7678d5f

Please sign in to comment.