Skip to content

Commit e82b5af

Browse files
committed
Shorten avifIOPartialRead() in avifincrtest_helpers
1 parent 1af7274 commit e82b5af

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

tests/avifincrtest_helpers.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,28 +117,14 @@ typedef struct
117117
size_t fullSize;
118118
} avifROPartialData;
119119

120-
// Implementation of avifIOReadFunc simulating a stream from an array.
120+
// Implementation of avifIOReadFunc simulating a stream from an array. See avifIOReadFunc documentation.
121121
// io->data is expected to point to avifROPartialData.
122122
static avifResult avifIOPartialRead(struct avifIO * io, uint32_t readFlags, uint64_t offset, size_t size, avifROData * out)
123123
{
124124
const avifROPartialData * data = (avifROPartialData *)io->data;
125-
126-
// The behavior below is described in the comment above avifIOReadFunc's declaration.
127-
if (readFlags != 0) {
128-
return AVIF_RESULT_IO_ERROR;
129-
}
130-
if (!data) {
125+
if ((readFlags != 0) || !data || (data->fullSize < offset)) {
131126
return AVIF_RESULT_IO_ERROR;
132127
}
133-
if (data->fullSize < offset) {
134-
return AVIF_RESULT_IO_ERROR;
135-
}
136-
if (data->fullSize == offset) {
137-
out->data = data->available.data;
138-
out->size = 0;
139-
return AVIF_RESULT_OK;
140-
}
141-
142128
if (data->fullSize < (offset + size)) {
143129
size = data->fullSize - offset;
144130
}

0 commit comments

Comments
 (0)