summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2020-12-14 21:49:19 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2020-12-14 21:49:19 +0000
commitcb32c3448837fbae9830b9df08f55bb096e8c687 (patch)
tree324bfe291ea7714e339c77e230f481807fe268d9
parent89a4cedc0d00fdea6f6c792baafe4cfc8e485fe0 (diff)
parent9d4d7e53539d1e9222fb9d4466700af37147b8e1 (diff)
downloadgdk-pixbuf-cb32c3448837fbae9830b9df08f55bb096e8c687.tar.gz
Merge branch 'wip/run-gif-tests-again' into 'master'
Run GIF tests again, and fix regression for short reads See merge request GNOME/gdk-pixbuf!95
-rw-r--r--gdk-pixbuf/io-gif.c27
-rw-r--r--tests/meson.build50
2 files changed, 38 insertions, 39 deletions
diff --git a/gdk-pixbuf/io-gif.c b/gdk-pixbuf/io-gif.c
index 57e72d88b..64a492a58 100644
--- a/gdk-pixbuf/io-gif.c
+++ b/gdk-pixbuf/io-gif.c
@@ -513,15 +513,22 @@ gif_prepare_lzw (GifContext *context)
return 0;
}
-/* needs 13 bytes to proceed. */
+/*
+ * Read the GIF signature and screen descriptor.
+ *
+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
+ * |-----------|-----------|-----------------------------------|
+ * | magic | version | screen descriptor |
+ * | G | I | F | 8 | 9 | a | width | height | colors | ignored |
+ */
static gint
gif_init (GifContext *context)
{
- unsigned char buf[16];
+ unsigned char buf[13];
char version[4];
gint width, height;
- if (!gif_read (context, buf, 6)) {
+ if (!gif_read (context, buf, 13)) {
/* Unable to read magic number,
* gif_read() should have set error
*/
@@ -554,22 +561,16 @@ gif_init (GifContext *context)
return -2;
}
- /* read the screen descriptor */
- if (!gif_read (context, buf, 7)) {
- /* Failed to read screen descriptor, error set */
- return -1;
- }
-
- context->width = LM_to_uint (buf[0], buf[1]);
- context->height = LM_to_uint (buf[2], buf[3]);
+ context->width = LM_to_uint (buf[6], buf[7]);
+ context->height = LM_to_uint (buf[8], buf[9]);
/* The 4th byte is
* high bit: whether to use the background index
* next 3: color resolution
* next: whether colormap is sorted by priority of allocation
* last 3: size of colormap
*/
- context->global_bit_pixel = 2 << (buf[4] & 0x07);
- context->has_global_cmap = (buf[4] & 0x80) != 0;
+ context->global_bit_pixel = 2 << (buf[10] & 0x07);
+ context->has_global_cmap = (buf[10] & 0x80) != 0;
context->animation->width = context->width;
context->animation->height = context->height;
diff --git a/tests/meson.build b/tests/meson.build
index c9cf25c6e..ab7ff1eee 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -1,6 +1,6 @@
# Resources contain PNG and BMP files, so we need these two loaders
# enabled in order to build them
-if enabled_loaders.contains('png') and enabled_loaders.contains('bmp')
+if enabled_loaders.contains('png')
# Resources; we cannot use gnome.compile_resources() here, because we need to
# override the environment in order to use the utilities we just built instead
# of the system ones
@@ -65,7 +65,6 @@ installed_tests = {
'pixbuf-construction': { 'suites': ['conform'], },
'animation': {
'suites': ['format'],
- 'skip': not enabled_loaders.contains('gif'),
},
'cve-2015-4491': {
'suites': ['security'],
@@ -107,11 +106,9 @@ installed_tests = {
'pixbuf-scale-two-step': { 'suites': ['ops'], },
'pixbuf-short-gif-write': {
'suites': ['format'],
- 'skip': not enabled_loaders.contains('gif'),
},
'pixbuf-gif-circular-table': {
'suites': ['format'],
- 'skip': not enabled_loaders.contains('gif'),
},
'pixbuf-save': { 'suites': ['io'] },
'pixbuf-readonly-to-mutable': { 'suites': ['conform'], },
@@ -174,6 +171,9 @@ foreach test_name, test_data: installed_tests
test_sources += [ resources_c, resources_h ]
endif
skip_if_true = test_data.get('skip', false)
+ if skip_if_true
+ continue
+ endif
custom_target(test_name + '.test',
output: test_name + '.test',
@@ -187,30 +187,28 @@ foreach test_name, test_data: installed_tests
install_dir: installed_test_datadir,
)
- if not skip_if_true
- test_bin = executable(test_name, test_sources,
- dependencies: test_deps,
- include_directories: [ root_inc, gdk_pixbuf_inc, ],
- c_args: common_cflags,
- install: get_option('installed_tests'),
- install_dir: installed_test_bindir,
- )
-
- # Two particularly slow tests
- if test_suites.contains('slow')
- timeout = 300
- else
- timeout = 30
- endif
+ test_bin = executable(test_name, test_sources,
+ dependencies: test_deps,
+ include_directories: [ root_inc, gdk_pixbuf_inc, ],
+ c_args: common_cflags,
+ install: get_option('installed_tests'),
+ install_dir: installed_test_bindir,
+ )
- test(test_name, test_bin,
- suite: test_suites,
- args: test_args,
- env: test_env,
- timeout: timeout,
- protocol: 'tap',
- )
+ # Two particularly slow tests
+ if test_suites.contains('slow')
+ timeout = 300
+ else
+ timeout = 30
endif
+
+ test(test_name, test_bin,
+ suite: test_suites,
+ args: test_args,
+ env: test_env,
+ timeout: timeout,
+ protocol: 'tap',
+ )
endforeach
executable('pixbuf-read',