Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Commit 483c93e

Browse files
committed
Fix handling of empty input
Fixes #166
1 parent 2b11bd9 commit 483c93e

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

guetzli/guetzli.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ std::string ReadFileOrDie(const char* filename) {
163163
off_t buffer_size = 8192;
164164

165165
if (fseek(f, 0, SEEK_END) == 0) {
166-
buffer_size = ftell(f);
166+
buffer_size = std::max<off_t>(ftell(f), 1);
167167
if (fseek(f, 0, SEEK_SET) != 0) {
168168
perror("fseek");
169169
exit(1);

tests/smoke_test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,10 @@ run_test png file stdout --nomemlimit
4949
run_test png file stdout --memlimit 100
5050
run_test png file stdout --quality 85
5151

52+
echo $GUETZLI /dev/null /dev/null
53+
$GUETZLI /dev/null /dev/null
54+
if [[ $? -ne 1 ]]; then
55+
echo "Expected a clean failure"
56+
exit 1
57+
fi
58+

0 commit comments

Comments
 (0)