From 902865c757f96923cc6ef90107fffcbadb6bbf4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 8 Feb 2012 10:11:42 -0500 Subject: [PATCH] cairo-util: Only look at first two bytes for jpegs The next two bytes aren't fixed. --- clients/cairo-util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/clients/cairo-util.c b/clients/cairo-util.c index bdad696a..2f780a77 100644 --- a/clients/cairo-util.c +++ b/clients/cairo-util.c @@ -1,5 +1,6 @@ /* * Copyright © 2008 Kristian Høgsberg + * Copyright © 2012 Intel Corporation * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -518,7 +519,7 @@ load_image(const char *filename) { cairo_surface_t *surface; static const unsigned char png_header[] = { 0x89, 'P', 'N', 'G' }; - static const unsigned char jpeg_header[] = { 0xff, 0xd8, 0xff, 0xe0 }; + static const unsigned char jpeg_header[] = { 0xff, 0xd8 }; unsigned char header[4]; FILE *fp; @@ -528,9 +529,9 @@ load_image(const char *filename) fread(header, sizeof header, 1, fp); rewind(fp); - if (memcmp(header, png_header, sizeof header) == 0) + if (memcmp(header, png_header, sizeof png_header) == 0) surface = load_png(fp); - else if (memcmp(header, jpeg_header, sizeof header) == 0) + else if (memcmp(header, jpeg_header, sizeof jpeg_header) == 0) surface = load_jpeg(fp); else { fprintf(stderr, "unrecognized file header for %s: "