Bug Summary

File:_build/../cdk-pixbuf/io-xbm.c
Warning:line 211, column 17
This statement is never executed

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -O2 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name io-xbm.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/rootdir/_build -fcoverage-compilation-dir=/rootdir/_build -resource-dir /usr/lib/llvm-21/lib/clang/21 -I cdk-pixbuf/libpixbufloader-xbm.so.p -I cdk-pixbuf -I ../cdk-pixbuf -I . -I .. -I /usr/include/libpng16 -I /usr/include/x86_64-linux-gnu -I /usr/include/webp -I /usr/include/librsvg-2.0 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glycin-2 -I /usr/include/cairo -I /usr/include/libxml2 -I /usr/include/pango-1.0 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/pixman-1 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -D _FILE_OFFSET_BITS=64 -D _POSIX_C_SOURCE=200809L -D _DEFAULT_SOURCE -D _XOPEN_SOURCE=700 -D HAVE_CONFIG_H=1 -D G_LOG_STRUCTURED=1 -D G_LOG_DOMAIN="CdkPixbuf" -D CDK_PIXBUF_COMPILATION -D CDK_PIXBUF_PREFIX="/usr/local" -D CDK_PIXBUF_LOCALEDIR="/usr/local/share/locale" -D CDK_PIXBUF_LIBDIR="/usr/local/lib/x86_64-linux-gnu" -D CDK_PIXBUF_BINARY_VERSION="2.10.0" -D CDK_PIXBUF_ENABLE_BACKEND -D PIXBUF_LIBDIR="/usr/local/lib/x86_64-linux-gnu/cdk-pixbuf-2.0/2.10.0/loaders" -D BUILT_MODULES_DIR="/rootdir/_build/cdk-pixbuf" -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/15/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-int-conversion -Wno-uninitialized -Wno-discarded-qualifiers -std=gnu99 -ferror-limit 19 -fvisibility=hidden -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-checker deadcode.DeadStores -analyzer-checker security.ArrayBound -analyzer-checker unix.cstring.NotNullTerminated -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2026-08-29-083117-8036-1 -x c ../cdk-pixbuf/io-xbm.c
1/* -*- mode: C; c-file-style: "linux" -*- */
2/* CdkPixbuf library - XBM image loader
3 *
4 * Copyright (C) 1999 Mark Crichton
5 * Copyright (C) 1999 The Free Software Foundation
6 * Copyright (C) 2001 Eazel, Inc.
7 *
8 * Authors: Mark Crichton <crichton@gimp.org>
9 * Federico Mena-Quintero <federico@gimp.org>
10 * Jonathan Blandford <jrb@redhat.com>
11 * John Harper <jsh@eazel.com>
12 *
13 * This library is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU Library General Public
15 * License as published by the Free Software Foundation; either
16 * version 2 of the License, or (at your option) any later version.
17 *
18 * This library is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * Library General Public License for more details.
22 *
23 * You should have received a copy of the GNU Library General Public
24 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
25 */
26
27/* Following code adapted from io-tiff.c, which was ``(almost) blatantly
28 ripped from Imlib'' */
29
30#include "config.h"
31#include <stdlib.h>
32#include <string.h>
33#ifdef HAVE_UNISTD_H1
34#include <unistd.h>
35#endif
36#include <stdio.h>
37#include <errno(*__errno_location ()).h>
38#include <glib/gstdio.h>
39#include <glib/gi18n-lib.h>
40
41#include "cdk-pixbuf-io.h"
42
43
44
45
46typedef struct _XBMData XBMData;
47struct _XBMData
48{
49 CdkPixbufModulePreparedFunc prepared_func;
50 CdkPixbufModuleUpdatedFunc updated_func;
51 gpointer user_data;
52
53 gchar *tempname;
54 FILE *file;
55 gboolean all_okay;
56};
57
58
59/* xbm parser borrowed from xc/lib/X11/RdBitF.c */
60
61#define MAX_SIZE255 255
62
63/* shared data for the image read/parse logic */
64static short hex_table[256]; /* conversion value */
65static gboolean initialized = FALSE(0); /* easier to fill in at run time */
66
67
68/* Table index for the hex values. Initialized once, first time.
69 * Used for translation value or delimiter significance lookup.
70 */
71static void
72init_hex_table (void)
73{
74 /*
75 * We build the table at run time for several reasons:
76 *
77 * 1. portable to non-ASCII machines.
78 * 2. still reentrant since we set the init flag after setting table.
79 * 3. easier to extend.
80 * 4. less prone to bugs.
81 */
82 hex_table['0'] = 0;
83 hex_table['1'] = 1;
84 hex_table['2'] = 2;
85 hex_table['3'] = 3;
86 hex_table['4'] = 4;
87 hex_table['5'] = 5;
88 hex_table['6'] = 6;
89 hex_table['7'] = 7;
90 hex_table['8'] = 8;
91 hex_table['9'] = 9;
92 hex_table['A'] = 10;
93 hex_table['B'] = 11;
94 hex_table['C'] = 12;
95 hex_table['D'] = 13;
96 hex_table['E'] = 14;
97 hex_table['F'] = 15;
98 hex_table['a'] = 10;
99 hex_table['b'] = 11;
100 hex_table['c'] = 12;
101 hex_table['d'] = 13;
102 hex_table['e'] = 14;
103 hex_table['f'] = 15;
104
105 /* delimiters of significance are flagged w/ negative value */
106 hex_table[' '] = -1;
107 hex_table[','] = -1;
108 hex_table['}'] = -1;
109 hex_table['\n'] = -1;
110 hex_table['\t'] = -1;
111
112 initialized = TRUE(!(0));
113}
114
115/* Read next hex value in the input stream, return -1 if EOF */
116static int
117next_int (FILE *fstream)
118{
119 int ch;
120 int value = 0;
121 int gotone = 0;
122 int done = 0;
123
124 /* loop, accumulate hex value until find delimiter
125 skip any initial delimiters found in read stream */
126
127 while (!done) {
128 ch = getc (fstream);
129 if (ch == EOF(-1)) {
130 value = -1;
131 done++;
132 } else {
133 /* trim high bits, check type and accumulate */
134 ch &= 0xff;
135 if (g_ascii_isxdigit (ch)((g_ascii_table[(guchar) (ch)] & G_ASCII_XDIGIT) != 0)) {
136 value = ((value & 0xf) << 4) + g_ascii_xdigit_value (ch);
137 gotone = 1;
138 } else if ((hex_table[ch]) < 0 && gotone) {
139 done++;
140 }
141 }
142 }
143 return value;
144}
145
146static gboolean
147read_bitmap_file_data (FILE *fstream,
148 guint *width,
149 guint *height,
150 guchar **data,
151 int *x_hot,
152 int *y_hot)
153{
154 guchar *bits = NULL((void*)0); /* working variable */
155 char line[MAX_SIZE255]; /* input line from file */
156 guint size; /* number of bytes of data */
157 char name_and_type[MAX_SIZE255]; /* an input line */
158 char *type; /* for parsing */
159 int value; /* from an input line */
160 int version10p; /* boolean, old format */
161 int padding; /* to handle alignment */
162 int bytes_per_line; /* per scanline of data */
163 guint ww = 0; /* width */
164 guint hh = 0; /* height */
165 int hx = -1; /* x hotspot */
166 int hy = -1; /* y hotspot */
167
168 /* first time initialization */
169 if (!initialized) {
170 init_hex_table ();
171 }
172
173 /* error cleanup and return macro */
174#define RETURN(code){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return code; }
{ g_free (bits)(__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits)
; return code; }
175
176 while (fgets (line, MAX_SIZE255, fstream)) {
177 if (strlen (line) == MAX_SIZE255-1)
178 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
179 if (sscanf (line,"#define %s %d",name_and_type,&value) == 2) {
180 if (!(type = strrchr (name_and_type, '_')))
181 type = name_and_type;
182 else {
183 type++;
184 }
185
186 if (!strcmp ("width", type)) {
187 if (value <= 0)
188 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
189 ww = (unsigned int) value;
190 }
191 if (!strcmp ("height", type)) {
192 if (value <= 0)
193 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
194 hh = (unsigned int) value;
195 }
196 if (!strcmp ("hot", type)) {
197 if (type-- == name_and_type
198 || type-- == name_and_type)
199 continue;
200 if (!strcmp ("x_hot", type))
201 hx = value;
202 if (!strcmp ("y_hot", type))
203 hy = value;
204 }
205 continue;
206 }
207
208 if (sscanf (line, "static short %s = {", name_and_type) == 1)
209 version10p = 1;
210 else if (sscanf (line,"static const unsigned char %s = {",name_and_type) == 1)
211 version10p = 0;
This statement is never executed
212 else if (sscanf (line,"static unsigned char %s = {",name_and_type) == 1)
213 version10p = 0;
214 else if (sscanf (line, "static const char %s = {", name_and_type) == 1)
215 version10p = 0;
216 else if (sscanf (line, "static char %s = {", name_and_type) == 1)
217 version10p = 0;
218 else
219 continue;
220
221 if (!(type = strrchr (name_and_type, '_')))
222 type = name_and_type;
223 else
224 type++;
225
226 if (strcmp ("bits[]", type))
227 continue;
228
229 if (!ww || !hh)
230 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
231
232 /* Choose @padding so @size is even if @version10p is %TRUE.
233 * If @version10p is %FALSE, @size could be even or odd. */
234 if ((ww % 16) && ((ww % 16) < 9) && version10p)
235 padding = 1;
236 else
237 padding = 0;
238
239 /* Check for overflow for the bytes_per_line calculation. */
240 if (ww > G_MAXUINT(2147483647 *2U +1U) - 7)
241 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
242
243 bytes_per_line = (ww+7)/8 + padding;
244 g_assert (!version10p || (bytes_per_line % 2) == 0)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_17
= 0; if (!version10p || (bytes_per_line % 2) == 0) _g_boolean_var_17
= 1; _g_boolean_var_17; }), 1)) ; else g_assertion_message_expr
("CdkPixbuf", "../cdk-pixbuf/io-xbm.c", 244, ((const char*) (
__func__)), "!version10p || (bytes_per_line % 2) == 0"); } while
(0)
;
245
246 /* size = bytes_per_line * hh */
247 if (!g_uint_checked_mul (&size, bytes_per_line, hh)(!__builtin_mul_overflow(bytes_per_line, hh, &size)))
248 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
249
250 bits = g_malloc (size);
251
252 if (version10p) {
253 unsigned char *ptr;
254 guint bytes;
255
256 /* @bytes is guaranteed not to overflow (which could
257 * happen if @size is the odd-valued %G_MAXUINT: @bytes would reach
258 * %G_MAXUINT-1 in the loop, then be incremented to %G_MAXUINT+1 on the
259 * next iteration) because @bytes_per_line is guaranteed to be even if
260 * @version10p is %TRUE (due to the selection of
261 * @padding in that case), so @size must be even too. */
262 g_assert ((size % 2) == 0)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_18
= 0; if ((size % 2) == 0) _g_boolean_var_18 = 1; _g_boolean_var_18
; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-xbm.c"
, 262, ((const char*) (__func__)), "(size % 2) == 0"); } while
(0)
;
263
264 for (bytes = 0, ptr = bits; bytes < size; (bytes += 2)) {
265 if ((value = next_int (fstream)) < 0)
266 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
267 *(ptr++) = value;
268 if (!padding || ((bytes+2) % bytes_per_line))
269 *(ptr++) = value >> 8;
270 }
271 } else {
272 unsigned char *ptr;
273 guint bytes;
274
275 for (bytes = 0, ptr = bits; bytes < size; bytes++, ptr++) {
276 if ((value = next_int (fstream)) < 0)
277 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
278 *ptr=value;
279 }
280 }
281 break;
282 }
283
284 if (!bits)
285 RETURN (FALSE){ (__builtin_object_size ((bits), 0) != ((size_t) - 1)) ? g_free_sized
(bits, __builtin_object_size ((bits), 0)) : (g_free) (bits);
return (0); }
;
286
287 *data = bits;
288 *width = ww;
289 *height = hh;
290 if (x_hot)
291 *x_hot = hx;
292 if (y_hot)
293 *y_hot = hy;
294
295 return TRUE(!(0));
296}
297
298
299
300static CdkPixbuf *
301cdk_pixbuf__xbm_image_load_real (FILE *f,
302 XBMData *context,
303 GError **error)
304{
305 guint w, h;
306 int x_hot, y_hot;
307 guchar *data = NULL((void*)0), *ptr;
308 guchar *pixels;
309 guint row_stride;
310 int x, y;
311 int reg = 0; /* Quiet compiler */
312 int bits;
313
314 CdkPixbuf *pixbuf;
315
316 if (!read_bitmap_file_data (f, &w, &h, &data, &x_hot, &y_hot)) {
317 g_set_error_literal (error,
318 CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (),
319 CDK_PIXBUF_ERROR_CORRUPT_IMAGE,
320 _("Invalid XBM file")((char *) g_dgettext ("cdk-pixbuf", "Invalid XBM file")));
321 return NULL((void*)0);
322 }
323
324 pixbuf = cdk_pixbuf_new (CDK_COLORSPACE_RGB, FALSE(0), 8, w, h);
325
326 if (pixbuf == NULL((void*)0)) {
327 g_free (data)(__builtin_object_size ((data), 0) != ((size_t) - 1)) ? g_free_sized
(data, __builtin_object_size ((data), 0)) : (g_free) (data)
;
328 g_set_error_literal (error,
329 CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (),
330 CDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
331 _("Insufficient memory to load XBM image file")((char *) g_dgettext ("cdk-pixbuf", "Insufficient memory to load XBM image file"
))
);
332 return NULL((void*)0);
333 }
334
335 if (x_hot != -1 && y_hot != -1) {
336 gchar hot[10];
337 g_snprintf (hot, 10, "%d", x_hot);
338 cdk_pixbuf_set_option (pixbuf, "x_hot", hot);
339 g_snprintf (hot, 10, "%d", y_hot);
340 cdk_pixbuf_set_option (pixbuf, "y_hot", hot);
341 }
342
343 pixels = cdk_pixbuf_get_pixels (pixbuf);
344 row_stride = cdk_pixbuf_get_rowstride (pixbuf);
345
346 if (context)
347 (* context->prepared_func) (pixbuf, NULL((void*)0), context->user_data);
348
349
350 /* Initialize PIXBUF */
351
352 ptr = data;
353 for (y = 0; y < h; y++) {
354 bits = 0;
355 for (x = 0; x < w; x++) {
356 guchar channel;
357 if (bits == 0) {
358 reg = *ptr++;
359 bits = 8;
360 }
361
362 channel = (reg & 1) ? 0 : 255;
363 reg >>= 1;
364 bits--;
365
366 pixels[x * 3 + 0] = channel;
367 pixels[x * 3 + 1] = channel;
368 pixels[x * 3 + 2] = channel;
369 }
370 pixels += row_stride;
371 }
372 g_free (data)(__builtin_object_size ((data), 0) != ((size_t) - 1)) ? g_free_sized
(data, __builtin_object_size ((data), 0)) : (g_free) (data)
;
373
374 if (context) {
375 (* context->updated_func) (pixbuf, 0, 0, w, h, context->user_data);
376 }
377
378 return pixbuf;
379}
380
381
382/* Static loader */
383
384static CdkPixbuf *
385cdk_pixbuf__xbm_image_load (FILE *f,
386 GError **error)
387{
388 return cdk_pixbuf__xbm_image_load_real (f, NULL((void*)0), error);
389}
390
391
392/* Progressive loader */
393
394/*
395 * Proper XBM progressive loading isn't implemented. Instead we write
396 * it to a file, then load the file when it's done. It's not pretty.
397 */
398
399static gpointer
400cdk_pixbuf__xbm_image_begin_load (CdkPixbufModuleSizeFunc size_func,
401 CdkPixbufModulePreparedFunc prepared_func,
402 CdkPixbufModuleUpdatedFunc updated_func,
403 gpointer user_data,
404 GError **error)
405{
406 XBMData *context;
407 gint fd;
408
409 g_assert (size_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_19
= 0; if (size_func != ((void*)0)) _g_boolean_var_19 = 1; _g_boolean_var_19
; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-xbm.c"
, 409, ((const char*) (__func__)), "size_func != NULL"); } while
(0)
;
410 g_assert (prepared_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_20
= 0; if (prepared_func != ((void*)0)) _g_boolean_var_20 = 1;
_g_boolean_var_20; }), 1)) ; else g_assertion_message_expr (
"CdkPixbuf", "../cdk-pixbuf/io-xbm.c", 410, ((const char*) (__func__
)), "prepared_func != NULL"); } while (0)
;
411 g_assert (updated_func != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_21
= 0; if (updated_func != ((void*)0)) _g_boolean_var_21 = 1; _g_boolean_var_21
; }), 1)) ; else g_assertion_message_expr ("CdkPixbuf", "../cdk-pixbuf/io-xbm.c"
, 411, ((const char*) (__func__)), "updated_func != NULL"); }
while (0)
;
412
413 context = g_new (XBMData, 1)(XBMData *) (__extension__ ({ gsize __n = (gsize) (1); gsize __s
= sizeof (XBMData); gpointer __p; if (__s == 1) __p = g_malloc
(__n); else if (__builtin_constant_p (__n) && (__s ==
0 || __n <= (9223372036854775807L *2UL+1UL) / __s)) __p =
g_malloc (__n * __s); else __p = g_malloc_n (__n, __s); __p;
}))
;
414 context->prepared_func = prepared_func;
415 context->updated_func = updated_func;
416 context->user_data = user_data;
417 context->all_okay = TRUE(!(0));
418 fd = g_file_open_tmp ("cdkpixbuf-xbm-tmp.XXXXXX",
419 &context->tempname,
420 NULL((void*)0));
421 if (fd < 0) {
422 g_free (context)(__builtin_object_size ((context), 0) != ((size_t) - 1)) ? g_free_sized
(context, __builtin_object_size ((context), 0)) : (g_free) (
context)
;
423 return NULL((void*)0);
424 }
425
426 context->file = fdopen (fd, "w+");
427 if (context->file == NULL((void*)0)) {
428 g_free (context->tempname)(__builtin_object_size ((context->tempname), 0) != ((size_t
) - 1)) ? g_free_sized (context->tempname, __builtin_object_size
((context->tempname), 0)) : (g_free) (context->tempname
)
;
429 g_free (context)(__builtin_object_size ((context), 0) != ((size_t) - 1)) ? g_free_sized
(context, __builtin_object_size ((context), 0)) : (g_free) (
context)
;
430 return NULL((void*)0);
431 }
432
433 return context;
434}
435
436static gboolean
437cdk_pixbuf__xbm_image_stop_load (gpointer data,
438 GError **error)
439{
440 XBMData *context = (XBMData*) data;
441 gboolean retval = TRUE(!(0));
442
443 g_return_val_if_fail (data != NULL, TRUE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_22
= 0; if (data != ((void*)0)) _g_boolean_var_22 = 1; _g_boolean_var_22
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "data != NULL"); return ((!(0))); }
} while (0)
;
444
445 fflush (context->file);
446 rewind (context->file);
447 if (context->all_okay) {
448 CdkPixbuf *pixbuf;
449 pixbuf = cdk_pixbuf__xbm_image_load_real (context->file,
450 context,
451 error);
452 if (pixbuf == NULL((void*)0))
453 retval = FALSE(0);
454 else
455 g_object_unref (pixbuf);
456 }
457
458 fclose (context->file);
459 g_unlink (context->tempname);
460 g_free (context->tempname)(__builtin_object_size ((context->tempname), 0) != ((size_t
) - 1)) ? g_free_sized (context->tempname, __builtin_object_size
((context->tempname), 0)) : (g_free) (context->tempname
)
;
461 g_free ((XBMData *) context)(__builtin_object_size (((XBMData *) context), 0) != ((size_t
) - 1)) ? g_free_sized ((XBMData *) context, __builtin_object_size
(((XBMData *) context), 0)) : (g_free) ((XBMData *) context)
;
462
463 return retval;
464}
465
466static gboolean
467cdk_pixbuf__xbm_image_load_increment (gpointer data,
468 const guchar *buf,
469 guint size,
470 GError **error)
471{
472 XBMData *context = (XBMData *) data;
473
474 g_return_val_if_fail (data != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_23
= 0; if (data != ((void*)0)) _g_boolean_var_23 = 1; _g_boolean_var_23
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "data != NULL"); return ((0)); } }
while (0)
;
475
476 if (fwrite (buf, sizeof (guchar), size, context->file) != size) {
477 gint save_errno = errno(*__errno_location ());
478 context->all_okay = FALSE(0);
479 g_set_error_literal (error,
480 G_FILE_ERRORg_file_error_quark (),
481 g_file_error_from_errno (save_errno),
482 _("Failed to write to temporary file when loading XBM image")((char *) g_dgettext ("cdk-pixbuf", "Failed to write to temporary file when loading XBM image"
))
);
483 return FALSE(0);
484 }
485
486 return TRUE(!(0));
487}
488
489#ifndef INCLUDE_xbm
490#define MODULE_ENTRY(function)__attribute__((visibility("default"))) void function G_MODULE_EXPORT__attribute__((visibility("default"))) void function
491#else
492#define MODULE_ENTRY(function)__attribute__((visibility("default"))) void function void _cdk_pixbuf__xbm_ ## function
493#endif
494
495MODULE_ENTRY (fill_vtable)__attribute__((visibility("default"))) void fill_vtable (CdkPixbufModule *module)
496{
497 module->load = cdk_pixbuf__xbm_image_load;
498 module->begin_load = cdk_pixbuf__xbm_image_begin_load;
499 module->stop_load = cdk_pixbuf__xbm_image_stop_load;
500 module->load_increment = cdk_pixbuf__xbm_image_load_increment;
501}
502
503MODULE_ENTRY (fill_info)__attribute__((visibility("default"))) void fill_info (CdkPixbufFormat *info)
504{
505 static const CdkPixbufModulePattern signature[] = {
506 { "#define ", NULL((void*)0), 100 },
507 { "/*", NULL((void*)0), 50 },
508 { NULL((void*)0), NULL((void*)0), 0 }
509 };
510 static const gchar *mime_types[] = {
511 "image/x-xbitmap",
512 NULL((void*)0)
513 };
514 static const gchar *extensions[] = {
515 "xbm",
516 NULL((void*)0)
517 };
518
519 info->name = "xbm";
520 info->signature = (CdkPixbufModulePattern *) signature;
521 info->description = NC_("image format", "XBM")("XBM");
522 info->mime_types = (gchar **) mime_types;
523 info->extensions = (gchar **) extensions;
524 info->flags = CDK_PIXBUF_FORMAT_THREADSAFE;
525 info->license = "LGPL";
526}