Bug Summary

File:_build/../cdk-pixbuf/cdk-pixbuf-loader.c
Warning:line 422, column 20
Access to field 'module_name' results in a dereference of a null pointer (loaded from field 'image_module')

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 cdk-pixbuf-loader.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/libcdk_pixbuf-2.0.so.0.4501.0.p -I cdk-pixbuf -I ../cdk-pixbuf -I . -I .. -I cdk-pixbuf/pixops -I ../cdk-pixbuf/pixops -I /usr/include/glib-2.0 -I /usr/lib/x86_64-linux-gnu/glib-2.0/include -I /usr/include/sysprof-6 -I /usr/include/libmount -I /usr/include/blkid -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-083513-8035-1 -x c ../cdk-pixbuf/cdk-pixbuf-loader.c
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2/* CdkPixbuf library - Progressive loader object
3 *
4 * Copyright (C) 1999 The Free Software Foundation
5 *
6 * Authors: Mark Crichton <crichton@gimp.org>
7 * Miguel de Icaza <miguel@gnu.org>
8 * Federico Mena-Quintero <federico@gimp.org>
9 * Jonathan Blandford <jrb@redhat.com>
10 *
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
23 */
24
25#include "config.h"
26#include <string.h>
27
28#include "cdk-pixbuf-private.h"
29#include "cdk-pixbuf-animation.h"
30#include "cdk-pixbuf-scaled-anim.h"
31#include "cdk-pixbuf-loader.h"
32#include "cdk-pixbuf-marshal.h"
33
34/**
35 * CdkPixbufLoader:
36 *
37 * Incremental image loader.
38 *
39 * `CdkPixbufLoader` provides a way for applications to drive the
40 * process of loading an image, by letting them send the image data
41 * directly to the loader instead of having the loader read the data
42 * from a file. Applications can use this functionality instead of
43 * `cdk_pixbuf_new_from_file()` or `cdk_pixbuf_animation_new_from_file()`
44 * when they need to parse image data in small chunks. For example,
45 * it should be used when reading an image from a (potentially) slow
46 * network connection, or when loading an extremely large file.
47 *
48 * To use `CdkPixbufLoader` to load an image, create a new instance,
49 * and call [method@CdkPixbuf.PixbufLoader.write] to send the data
50 * to it. When done, [method@CdkPixbuf.PixbufLoader.close] should be
51 * called to end the stream and finalize everything.
52 *
53 * The loader will emit three important signals throughout the process:
54 *
55 * - [signal@CdkPixbuf.PixbufLoader::size-prepared] will be emitted as
56 * soon as the image has enough information to determine the size of
57 * the image to be used. If you want to scale the image while loading
58 * it, you can call [method@CdkPixbuf.PixbufLoader.set_size] in
59 * response to this signal.
60 * - [signal@CdkPixbuf.PixbufLoader::area-prepared] will be emitted as
61 * soon as the pixbuf of the desired has been allocated. You can obtain
62 * the `CdkPixbuf` instance by calling [method@CdkPixbuf.PixbufLoader.get_pixbuf].
63 * If you want to use it, simply acquire a reference to it. You can
64 * also call `cdk_pixbuf_loader_get_pixbuf()` later to get the same
65 * pixbuf.
66 * - [signal@CdkPixbuf.PixbufLoader::area-updated] will be emitted every
67 * time a region is updated. This way you can update a partially
68 * completed image. Note that you do not know anything about the
69 * completeness of an image from the updated area. For example, in an
70 * interlaced image you will need to make several passes before the
71 * image is done loading.
72 *
73 * ## Loading an animation
74 *
75 * Loading an animation is almost as easy as loading an image. Once the
76 * first [signal@CdkPixbuf.PixbufLoader::area-prepared] signal has been
77 * emitted, you can call [method@CdkPixbuf.PixbufLoader.get_animation] to
78 * get the [class@CdkPixbuf.PixbufAnimation] instance, and then call
79 * and [method@CdkPixbuf.PixbufAnimation.get_iter] to get a
80 * [class@CdkPixbuf.PixbufAnimationIter] to retrieve the pixbuf for the
81 * desired time stamp.
82 */
83
84
85enum {
86 SIZE_PREPARED,
87 AREA_PREPARED,
88 AREA_UPDATED,
89 CLOSED,
90 LAST_SIGNAL
91};
92
93
94static void cdk_pixbuf_loader_finalize (GObject *loader);
95
96static guint pixbuf_loader_signals[LAST_SIGNAL] = { 0 };
97
98/* Internal data */
99
100typedef struct
101{
102 CdkPixbufAnimation *animation;
103 gboolean closed;
104 guchar header_buf[SNIFF_BUFFER_SIZE4096];
105 gint header_buf_offset;
106 CdkPixbufModule *image_module;
107 gpointer context;
108 gint original_width;
109 gint original_height;
110 gint width;
111 gint height;
112 gboolean size_fixed;
113 gboolean needs_scale;
114 gchar *filename;
115} CdkPixbufLoaderPrivate;
116
117G_DEFINE_TYPE (CdkPixbufLoader, cdk_pixbuf_loader, G_TYPE_OBJECT)static void cdk_pixbuf_loader_init (CdkPixbufLoader *self); static
void cdk_pixbuf_loader_class_init (CdkPixbufLoaderClass *klass
); static GType cdk_pixbuf_loader_get_type_once (void); static
gpointer cdk_pixbuf_loader_parent_class = ((void*)0); static
gint CdkPixbufLoader_private_offset; static void cdk_pixbuf_loader_class_intern_init
(gpointer klass) { cdk_pixbuf_loader_parent_class = g_type_class_peek_parent
(klass); if (CdkPixbufLoader_private_offset != 0) g_type_class_adjust_private_offset
(klass, &CdkPixbufLoader_private_offset); cdk_pixbuf_loader_class_init
((CdkPixbufLoaderClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer cdk_pixbuf_loader_get_instance_private
(CdkPixbufLoader *self) { return (((gpointer) ((guint8*) (self
) + (glong) (CdkPixbufLoader_private_offset)))); } GType cdk_pixbuf_loader_get_type
(void) { static GType static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) * (&static_g_define_type_id) : ((void*)0))
; (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter_pointer (
&static_g_define_type_id)); })) ) { GType g_define_type_id
= cdk_pixbuf_loader_get_type_once (); (__extension__ ({ _Static_assert
(sizeof *(&static_g_define_type_id) == sizeof (gpointer)
, "Expression evaluates to false"); 0 ? (void) (*(&static_g_define_type_id
) = (g_define_type_id)) : (void) 0; g_once_init_leave_pointer
((&static_g_define_type_id), (gpointer) (guintptr) (g_define_type_id
)); })) ; } return static_g_define_type_id; } __attribute__ (
(__noinline__)) static GType cdk_pixbuf_loader_get_type_once (
void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("CdkPixbufLoader"
), sizeof (CdkPixbufLoaderClass), (GClassInitFunc)(void (*)(void
)) cdk_pixbuf_loader_class_intern_init, sizeof (CdkPixbufLoader
), (GInstanceInitFunc)(void (*)(void)) cdk_pixbuf_loader_init
, (GTypeFlags) 0); { {{};} } return g_define_type_id; }
118
119
120static void
121cdk_pixbuf_loader_class_init (CdkPixbufLoaderClass *class)
122{
123 GObjectClass *object_class;
124
125 object_class = (GObjectClass *) class;
126
127 object_class->finalize = cdk_pixbuf_loader_finalize;
128
129 /**
130 * CdkPixbufLoader::size-prepared:
131 * @loader: the object which received the signal.
132 * @width: the original width of the image
133 * @height: the original height of the image
134 *
135 * This signal is emitted when the pixbuf loader has been fed the
136 * initial amount of data that is required to figure out the size
137 * of the image that it will create.
138 *
139 * Applications can call cdk_pixbuf_loader_set_size() in response
140 * to this signal to set the desired size to which the image
141 * should be scaled.
142 */
143 pixbuf_loader_signals[SIZE_PREPARED] =
144 g_signal_new ("size-prepared",
145 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
146 G_SIGNAL_RUN_LAST,
147 G_STRUCT_OFFSET (CdkPixbufLoaderClass, size_prepared)((glong) __builtin_offsetof(CdkPixbufLoaderClass, size_prepared
))
,
148 NULL((void*)0), NULL((void*)0),
149 _cdk_pixbuf_marshal_VOID__INT_INT,
150 G_TYPE_NONE((GType) ((1) << (2))), 2,
151 G_TYPE_INT((GType) ((6) << (2))),
152 G_TYPE_INT((GType) ((6) << (2))));
153
154 /**
155 * CdkPixbufLoader::area-prepared:
156 * @loader: the object which received the signal.
157 *
158 * This signal is emitted when the pixbuf loader has allocated the
159 * pixbuf in the desired size.
160 *
161 * After this signal is emitted, applications can call
162 * cdk_pixbuf_loader_get_pixbuf() to fetch the partially-loaded
163 * pixbuf.
164 */
165 pixbuf_loader_signals[AREA_PREPARED] =
166 g_signal_new ("area-prepared",
167 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
168 G_SIGNAL_RUN_LAST,
169 G_STRUCT_OFFSET (CdkPixbufLoaderClass, area_prepared)((glong) __builtin_offsetof(CdkPixbufLoaderClass, area_prepared
))
,
170 NULL((void*)0), NULL((void*)0),
171 _cdk_pixbuf_marshal_VOID__VOIDg_cclosure_marshal_VOID__VOID,
172 G_TYPE_NONE((GType) ((1) << (2))), 0);
173
174 /**
175 * CdkPixbufLoader::area-updated:
176 * @loader: the object which received the signal.
177 * @x: X offset of upper-left corner of the updated area.
178 * @y: Y offset of upper-left corner of the updated area.
179 * @width: Width of updated area.
180 * @height: Height of updated area.
181 *
182 * This signal is emitted when a significant area of the image being
183 * loaded has been updated.
184 *
185 * Normally it means that a complete scanline has been read in, but
186 * it could be a different area as well.
187 *
188 * Applications can use this signal to know when to repaint
189 * areas of an image that is being loaded.
190 */
191 pixbuf_loader_signals[AREA_UPDATED] =
192 g_signal_new ("area-updated",
193 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
194 G_SIGNAL_RUN_LAST,
195 G_STRUCT_OFFSET (CdkPixbufLoaderClass, area_updated)((glong) __builtin_offsetof(CdkPixbufLoaderClass, area_updated
))
,
196 NULL((void*)0), NULL((void*)0),
197 _cdk_pixbuf_marshal_VOID__INT_INT_INT_INT,
198 G_TYPE_NONE((GType) ((1) << (2))), 4,
199 G_TYPE_INT((GType) ((6) << (2))),
200 G_TYPE_INT((GType) ((6) << (2))),
201 G_TYPE_INT((GType) ((6) << (2))),
202 G_TYPE_INT((GType) ((6) << (2))));
203
204 /**
205 * CdkPixbufLoader::closed:
206 * @loader: the object which received the signal.
207 *
208 * This signal is emitted when cdk_pixbuf_loader_close() is called.
209 *
210 * It can be used by different parts of an application to receive
211 * notification when an image loader is closed by the code that
212 * drives it.
213 */
214 pixbuf_loader_signals[CLOSED] =
215 g_signal_new ("closed",
216 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
217 G_SIGNAL_RUN_LAST,
218 G_STRUCT_OFFSET (CdkPixbufLoaderClass, closed)((glong) __builtin_offsetof(CdkPixbufLoaderClass, closed)),
219 NULL((void*)0), NULL((void*)0),
220 _cdk_pixbuf_marshal_VOID__VOIDg_cclosure_marshal_VOID__VOID,
221 G_TYPE_NONE((GType) ((1) << (2))), 0);
222}
223
224static void
225cdk_pixbuf_loader_init (CdkPixbufLoader *loader)
226{
227 CdkPixbufLoaderPrivate *priv;
228
229 priv = g_new0 (CdkPixbufLoaderPrivate, 1)(CdkPixbufLoaderPrivate *) (__extension__ ({ gsize __n = (gsize
) (1); gsize __s = sizeof (CdkPixbufLoaderPrivate); gpointer __p
; if (__s == 1) __p = g_malloc0 (__n); else if (__builtin_constant_p
(__n) && (__s == 0 || __n <= (9223372036854775807L
*2UL+1UL) / __s)) __p = g_malloc0 (__n * __s); else __p = g_malloc0_n
(__n, __s); __p; }))
;
230 priv->original_width = -1;
231 priv->original_height = -1;
232 priv->width = -1;
233 priv->height = -1;
234
235 loader->priv = priv;
236}
237
238static void
239cdk_pixbuf_loader_finalize (GObject *object)
240{
241 CdkPixbufLoader *loader;
242 CdkPixbufLoaderPrivate *priv = NULL((void*)0);
243
244 loader = CDK_PIXBUF_LOADER (object)((((CdkPixbufLoader*) (void *) ((object)))));
245 priv = loader->priv;
246
247 if (!priv->closed) {
248 g_warning ("CdkPixbufLoader finalized without calling cdk_pixbuf_loader_close() - this is not allowed. You must explicitly end the data stream to the loader before dropping the last reference.");
249 }
250 if (priv->animation)
251 g_object_unref (priv->animation);
252
253 g_free (priv->filename)(__builtin_object_size ((priv->filename), 0) != ((size_t) -
1)) ? g_free_sized (priv->filename, __builtin_object_size
((priv->filename), 0)) : (g_free) (priv->filename)
;
254
255 g_free (priv)(__builtin_object_size ((priv), 0) != ((size_t) - 1)) ? g_free_sized
(priv, __builtin_object_size ((priv), 0)) : (g_free) (priv)
;
256
257 G_OBJECT_CLASS (cdk_pixbuf_loader_parent_class)((((GObjectClass*) (void *) ((cdk_pixbuf_loader_parent_class)
))))
->finalize (object);
258}
259
260/**
261 * cdk_pixbuf_loader_set_size:
262 * @loader: A pixbuf loader.
263 * @width: The desired width of the image being loaded.
264 * @height: The desired height of the image being loaded.
265 *
266 * Causes the image to be scaled while it is loaded.
267 *
268 * The desired image size can be determined relative to the original
269 * size of the image by calling cdk_pixbuf_loader_set_size() from a
270 * signal handler for the ::size-prepared signal.
271 *
272 * Attempts to set the desired image size are ignored after the
273 * emission of the ::size-prepared signal.
274 *
275 * Since: 2.2
276 */
277void
278cdk_pixbuf_loader_set_size (CdkPixbufLoader *loader,
279 gint width,
280 gint height)
281{
282 CdkPixbufLoaderPrivate *priv;
283
284 g_return_if_fail (CDK_IS_PIXBUF_LOADER (loader))do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_27
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_27 = 1; _g_boolean_var_27; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return; } } while (0)
;
285 g_return_if_fail (width >= 0 && height >= 0)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_28
= 0; if (width >= 0 && height >= 0) _g_boolean_var_28
= 1; _g_boolean_var_28; }), 1))) { } else { g_return_if_fail_warning
("CdkPixbuf", ((const char*) (__func__)), "width >= 0 && height >= 0"
); return; } } while (0)
;
286
287 priv = CDK_PIXBUF_LOADER (loader)((((CdkPixbufLoader*) (void *) ((loader)))))->priv;
288
289 if (!priv->size_fixed)
290 {
291 priv->width = width;
292 priv->height = height;
293 }
294}
295
296static void
297cdk_pixbuf_loader_size_func (gint *width, gint *height, gpointer loader)
298{
299 CdkPixbufLoaderPrivate *priv = CDK_PIXBUF_LOADER (loader)((((CdkPixbufLoader*) (void *) ((loader)))))->priv;
300
301 priv->original_width = *width;
302 priv->original_height = *height;
303
304 /* allow calling cdk_pixbuf_loader_set_size() before the signal */
305 if (priv->width == -1 && priv->height == -1)
306 {
307 priv->width = *width;
308 priv->height = *height;
309 }
310
311 g_signal_emit (loader, pixbuf_loader_signals[SIZE_PREPARED], 0, *width, *height);
312 priv->size_fixed = TRUE(!(0));
313
314 *width = priv->width;
315 *height = priv->height;
316}
317
318static void
319cdk_pixbuf_loader_prepare (CdkPixbuf *pixbuf,
320 CdkPixbufAnimation *anim,
321 gpointer loader)
322{
323 CdkPixbufLoaderPrivate *priv = CDK_PIXBUF_LOADER (loader)((((CdkPixbufLoader*) (void *) ((loader)))))->priv;
324 gint width, height;
325 g_return_if_fail (pixbuf != NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_29
= 0; if (pixbuf != ((void*)0)) _g_boolean_var_29 = 1; _g_boolean_var_29
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "pixbuf != NULL"); return; } } while
(0)
;
326
327G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
328
329 width = anim ? cdk_pixbuf_animation_get_width (anim) :
330 cdk_pixbuf_get_width (pixbuf);
331 height = anim ? cdk_pixbuf_animation_get_height (anim) :
332 cdk_pixbuf_get_height (pixbuf);
333
334G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
335
336 if (!priv->size_fixed)
337 {
338 gint w = width;
339 gint h = height;
340 /* Defend against lazy loaders which don't call size_func */
341 cdk_pixbuf_loader_size_func (&w, &h, loader);
342 }
343
344 priv->needs_scale = FALSE(0);
345 if (priv->width > 0 && priv->height > 0 &&
346 (priv->width != width || priv->height != height))
347 priv->needs_scale = TRUE(!(0));
348
349 if (anim)
350 g_object_ref (anim)((__typeof__ (anim)) (g_object_ref) (anim));
351 else {
352 if (priv->original_width > 0) {
353 char *original_width_str = NULL((void*)0);
354
355 original_width_str = g_strdup_printf ("%d", priv->original_width);
356 cdk_pixbuf_set_option (pixbuf, "original-width", original_width_str);
357 g_free (original_width_str)(__builtin_object_size ((original_width_str), 0) != ((size_t)
- 1)) ? g_free_sized (original_width_str, __builtin_object_size
((original_width_str), 0)) : (g_free) (original_width_str)
;
358 }
359
360 if (priv->original_height > 0) {
361 char *original_height_str = NULL((void*)0);
362
363 original_height_str = g_strdup_printf ("%d", priv->original_height);
364 cdk_pixbuf_set_option (pixbuf, "original-height", original_height_str);
365 g_free (original_height_str)(__builtin_object_size ((original_height_str), 0) != ((size_t
) - 1)) ? g_free_sized (original_height_str, __builtin_object_size
((original_height_str), 0)) : (g_free) (original_height_str)
;
366 }
367
368G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
369 anim = cdk_pixbuf_non_anim_new (pixbuf);
370G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
371 }
372
373G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
374 if (priv->needs_scale && width != 0 && height != 0) {
375 priv->animation = CDK_PIXBUF_ANIMATION (_cdk_pixbuf_scaled_anim_new (anim,((((CdkPixbufAnimation*) (void *) ((_cdk_pixbuf_scaled_anim_new
(anim, (double) priv->width / width, (double) priv->height
/ height, 1.0))))))
376 (double) priv->width / width,((((CdkPixbufAnimation*) (void *) ((_cdk_pixbuf_scaled_anim_new
(anim, (double) priv->width / width, (double) priv->height
/ height, 1.0))))))
377 (double) priv->height / height,((((CdkPixbufAnimation*) (void *) ((_cdk_pixbuf_scaled_anim_new
(anim, (double) priv->width / width, (double) priv->height
/ height, 1.0))))))
378 1.0))((((CdkPixbufAnimation*) (void *) ((_cdk_pixbuf_scaled_anim_new
(anim, (double) priv->width / width, (double) priv->height
/ height, 1.0))))))
;
379 g_object_unref (anim);
380 }
381 else
382 priv->animation = anim;
383G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
384
385 if (!priv->needs_scale)
386 g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
387}
388
389static void
390cdk_pixbuf_loader_update (CdkPixbuf *pixbuf,
391 gint x,
392 gint y,
393 gint width,
394 gint height,
395 gpointer loader)
396{
397 CdkPixbufLoaderPrivate *priv = CDK_PIXBUF_LOADER (loader)((((CdkPixbufLoader*) (void *) ((loader)))))->priv;
398
399G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
400 if (!priv->needs_scale)
401 g_signal_emit (loader,
402 pixbuf_loader_signals[AREA_UPDATED],
403 0,
404 x, y,
405 /* sanity check in here. Defend against an errant loader */
406 MIN (width, cdk_pixbuf_animation_get_width (priv->animation))(((width) < (cdk_pixbuf_animation_get_width (priv->animation
))) ? (width) : (cdk_pixbuf_animation_get_width (priv->animation
)))
,
407 MIN (height, cdk_pixbuf_animation_get_height (priv->animation))(((height) < (cdk_pixbuf_animation_get_height (priv->animation
))) ? (height) : (cdk_pixbuf_animation_get_height (priv->animation
)))
);
408G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
409}
410
411/* Defense against broken loaders; DO NOT take this as a GError example! */
412static void
413cdk_pixbuf_loader_ensure_error (CdkPixbufLoader *loader,
414 GError **error)
415{
416 CdkPixbufLoaderPrivate *priv = loader->priv;
417
418 if (error
40.1
'error' is not equal to NULL
== NULL((void*)0) || *error != NULL((void*)0))
41
Taking false branch
419 return;
420
421 g_warning ("Bug! loader '%s' didn't set an error on failure",
422 priv->image_module->module_name);
42
Access to field 'module_name' results in a dereference of a null pointer (loaded from field 'image_module')
423 g_set_error (error,
424 CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (),
425 CDK_PIXBUF_ERROR_FAILED,
426 _("Internal error: Image loader module “%s” failed to"((char *) g_dgettext ("cdk-pixbuf", "Internal error: Image loader module “%s” failed to"
" complete an operation, but didn’t give a reason for" " the failure"
))
427 " complete an operation, but didn’t give a reason for"((char *) g_dgettext ("cdk-pixbuf", "Internal error: Image loader module “%s” failed to"
" complete an operation, but didn’t give a reason for" " the failure"
))
428 " the failure")((char *) g_dgettext ("cdk-pixbuf", "Internal error: Image loader module “%s” failed to"
" complete an operation, but didn’t give a reason for" " the failure"
))
,
429 priv->image_module->module_name);
430}
431
432static gint
433cdk_pixbuf_loader_load_module (CdkPixbufLoader *loader,
434 const char *image_type,
435 GError **error)
436{
437 CdkPixbufLoaderPrivate *priv = loader->priv;
438
439 if (image_type)
440 {
441 priv->image_module = _cdk_pixbuf_get_named_module (image_type,
442 error);
443 }
444 else
445 {
446 priv->image_module = _cdk_pixbuf_get_module (priv->header_buf,
447 priv->header_buf_offset,
448 priv->filename,
449 error);
450 }
451
452 if (priv->image_module == NULL((void*)0))
453 return 0;
454
455 if (!_cdk_pixbuf_load_module (priv->image_module, error))
456 return 0;
457
458 if (priv->image_module->module == NULL((void*)0))
459 return 0;
460
461 if ((priv->image_module->begin_load == NULL((void*)0)) ||
462 (priv->image_module->stop_load == NULL((void*)0)) ||
463 (priv->image_module->load_increment == NULL((void*)0)))
464 {
465 g_set_error (error,
466 CDK_PIXBUF_ERRORcdk_pixbuf_error_quark (),
467 CDK_PIXBUF_ERROR_UNSUPPORTED_OPERATION,
468 _("Incremental loading of image type “%s” is not supported")((char *) g_dgettext ("cdk-pixbuf", "Incremental loading of image type “%s” is not supported"
))
,
469 priv->image_module->module_name);
470
471 return 0;
472 }
473
474 priv->context = priv->image_module->begin_load (cdk_pixbuf_loader_size_func,
475 cdk_pixbuf_loader_prepare,
476 cdk_pixbuf_loader_update,
477 loader,
478 error);
479
480 if (priv->context == NULL((void*)0))
481 {
482 cdk_pixbuf_loader_ensure_error (loader, error);
483 return 0;
484 }
485
486 if (priv->header_buf_offset
487 && priv->image_module->load_increment (priv->context, priv->header_buf, priv->header_buf_offset, error))
488 return priv->header_buf_offset;
489
490 return 0;
491}
492
493static int
494cdk_pixbuf_loader_eat_header_write (CdkPixbufLoader *loader,
495 const guchar *buf,
496 gsize count,
497 GError **error)
498{
499 gint n_bytes;
500 CdkPixbufLoaderPrivate *priv = loader->priv;
501
502 n_bytes = MIN(SNIFF_BUFFER_SIZE - priv->header_buf_offset, count)(((4096 - priv->header_buf_offset) < (count)) ? (4096 -
priv->header_buf_offset) : (count))
;
503 memcpy (priv->header_buf + priv->header_buf_offset, buf, n_bytes);
504
505 priv->header_buf_offset += n_bytes;
506
507 if (priv->header_buf_offset >= SNIFF_BUFFER_SIZE4096)
508 {
509 if (cdk_pixbuf_loader_load_module (loader, NULL((void*)0), error) == 0)
510 return 0;
511 }
512
513 return n_bytes;
514}
515
516/**
517 * cdk_pixbuf_loader_write:
518 * @loader: A pixbuf loader.
519 * @buf: (array length=count): Pointer to image data.
520 * @count: Length of the @buf buffer in bytes.
521 * @error: return location for errors
522 *
523 * Parses the next `count` bytes in the given image buffer.
524 *
525 * Return value: `TRUE` if the write was successful, or
526 * `FALSE` if the loader cannot parse the buffer
527 **/
528gboolean
529cdk_pixbuf_loader_write (CdkPixbufLoader *loader,
530 const guchar *buf,
531 gsize count,
532 GError **error)
533{
534 CdkPixbufLoaderPrivate *priv;
535
536 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_30
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_30 = 1; _g_boolean_var_30; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return ((0)); } } while
(0)
;
18
Taking false branch
19
Assuming the condition is true
20
Taking true branch
21
Taking true branch
22
Loop condition is false. Exiting loop
537
538 g_return_val_if_fail (buf != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_31
= 0; if (buf != ((void*)0)) _g_boolean_var_31 = 1; _g_boolean_var_31
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "buf != NULL"); return ((0)); } } while
(0)
;
23
Assuming 'buf' is not equal to null
24
Taking true branch
25
Taking true branch
26
Loop condition is false. Exiting loop
539 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_32
= 0; if (error == ((void*)0) || *error == ((void*)0)) _g_boolean_var_32
= 1; _g_boolean_var_32; }), 1))) { } else { g_return_if_fail_warning
("CdkPixbuf", ((const char*) (__func__)), "error == NULL || *error == NULL"
); return ((0)); } } while (0)
;
27
Taking true branch
28
Taking true branch
29
Loop condition is false. Exiting loop
540
541 priv = loader->priv;
542
543 /* we expect it's not to be closed */
544 g_return_val_if_fail (priv->closed == FALSE, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_33
= 0; if (priv->closed == (0)) _g_boolean_var_33 = 1; _g_boolean_var_33
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "priv->closed == FALSE"); return
((0)); } } while (0)
;
30
Assuming field 'closed' is equal to 0
31
Taking true branch
32
Taking true branch
545
546 if (count > 0 && priv->image_module == NULL((void*)0))
33
Loop condition is false. Exiting loop
34
Assuming 'count' is > 0
35
Assuming field 'image_module' is equal to NULL
36
Taking true branch
547 {
548 gint eaten;
549
550 eaten = cdk_pixbuf_loader_eat_header_write (loader, buf, count, error);
551 if (eaten <= 0)
37
Assuming 'eaten' is <= 0
38
Taking true branch
552 goto fail;
39
Control jumps to line 571
553
554 count -= eaten;
555 buf += eaten;
556 }
557
558 /* By this point, we expect the image_module to have been loaded. */
559 g_assert (count == 0 || priv->image_module != NULL)do { if (__builtin_expect (__extension__ ({ int _g_boolean_var_34
= 0; if (count == 0 || priv->image_module != ((void*)0)) _g_boolean_var_34
= 1; _g_boolean_var_34; }), 1)) ; else g_assertion_message_expr
("CdkPixbuf", "../cdk-pixbuf/cdk-pixbuf-loader.c", 559, ((const
char*) (__func__)), "count == 0 || priv->image_module != NULL"
); } while (0)
;
560
561 if (count > 0 && priv->image_module->load_increment != NULL((void*)0))
562 {
563 if (!priv->image_module->load_increment (priv->context, buf, count,
564 error))
565 goto fail;
566 }
567
568 return TRUE(!(0));
569
570 fail:
571 cdk_pixbuf_loader_ensure_error (loader, error);
40
Calling 'cdk_pixbuf_loader_ensure_error'
572 cdk_pixbuf_loader_close (loader, NULL((void*)0));
573
574 return FALSE(0);
575}
576
577/**
578 * cdk_pixbuf_loader_write_bytes:
579 * @loader: A pixbuf loader.
580 * @buffer: The image data as a `GBytes` buffer.
581 * @error: return location for errors
582 *
583 * Parses the next contents of the given image buffer.
584 *
585 * Return value: `TRUE` if the write was successful, or `FALSE` if
586 * the loader cannot parse the buffer
587 *
588 * Since: 2.30
589 */
590gboolean
591cdk_pixbuf_loader_write_bytes (CdkPixbufLoader *loader,
592 GBytes *buffer,
593 GError **error)
594{
595 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_35
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_35 = 1; _g_boolean_var_35; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return ((0)); } } while
(0)
;
1
Assuming '__inst' is non-null
2
Taking false branch
3
Assuming field 'g_class' is null
4
Assuming the condition is true
5
Taking true branch
6
Taking true branch
7
Loop condition is false. Exiting loop
596
597 g_return_val_if_fail (buffer != NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_36
= 0; if (buffer != ((void*)0)) _g_boolean_var_36 = 1; _g_boolean_var_36
; }), 1))) { } else { g_return_if_fail_warning ("CdkPixbuf", (
(const char*) (__func__)), "buffer != NULL"); return ((0)); }
} while (0)
;
8
Assuming 'buffer' is not equal to null
9
Taking true branch
10
Taking true branch
11
Loop condition is false. Exiting loop
598 g_return_val_if_fail (error == NULL || *error == NULL, FALSE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_37
= 0; if (error == ((void*)0) || *error == ((void*)0)) _g_boolean_var_37
= 1; _g_boolean_var_37; }), 1))) { } else { g_return_if_fail_warning
("CdkPixbuf", ((const char*) (__func__)), "error == NULL || *error == NULL"
); return ((0)); } } while (0)
;
12
Assuming 'error' is not equal to null
13
Assuming the condition is true
14
Taking true branch
15
Taking true branch
16
Loop condition is false. Exiting loop
599
600 return cdk_pixbuf_loader_write (loader,
17
Calling 'cdk_pixbuf_loader_write'
601 g_bytes_get_data (buffer, NULL((void*)0)),
602 g_bytes_get_size (buffer),
603 error);
604}
605
606/**
607 * cdk_pixbuf_loader_new:
608 *
609 * Creates a new pixbuf loader object.
610 *
611 * Return value: A newly-created pixbuf loader.
612 **/
613CdkPixbufLoader *
614cdk_pixbuf_loader_new (void)
615{
616 return g_object_new (CDK_TYPE_PIXBUF_LOADER(cdk_pixbuf_loader_get_type ()), NULL((void*)0));
617}
618
619/**
620 * cdk_pixbuf_loader_new_with_type:
621 * @image_type: name of the image format to be loaded with the image
622 * @error: (allow-none): return location for an allocated #GError, or `NULL` to ignore errors
623 *
624 * Creates a new pixbuf loader object that always attempts to parse
625 * image data as if it were an image of type @image_type, instead of
626 * identifying the type automatically.
627 *
628 * This function is useful if you want an error if the image isn't the
629 * expected type; for loading image formats that can't be reliably
630 * identified by looking at the data; or if the user manually forces
631 * a specific type.
632 *
633 * The list of supported image formats depends on what image loaders
634 * are installed, but typically "png", "jpeg", "gif", "tiff" and
635 * "xpm" are among the supported formats. To obtain the full list of
636 * supported image formats, call cdk_pixbuf_format_get_name() on each
637 * of the #CdkPixbufFormat structs returned by cdk_pixbuf_get_formats().
638 *
639 * Return value: A newly-created pixbuf loader.
640 **/
641CdkPixbufLoader *
642cdk_pixbuf_loader_new_with_type (const char *image_type,
643 GError **error)
644{
645 CdkPixbufLoader *retval;
646 GError *tmp;
647 g_return_val_if_fail (error == NULL || *error == NULL, NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_38
= 0; if (error == ((void*)0) || *error == ((void*)0)) _g_boolean_var_38
= 1; _g_boolean_var_38; }), 1))) { } else { g_return_if_fail_warning
("CdkPixbuf", ((const char*) (__func__)), "error == NULL || *error == NULL"
); return (((void*)0)); } } while (0)
;
648
649 retval = g_object_new (CDK_TYPE_PIXBUF_LOADER(cdk_pixbuf_loader_get_type ()), NULL((void*)0));
650
651 tmp = NULL((void*)0);
652 cdk_pixbuf_loader_load_module (retval, image_type, &tmp);
653 if (tmp != NULL((void*)0))
654 {
655 g_propagate_error (error, tmp);
656 cdk_pixbuf_loader_close (retval, NULL((void*)0));
657 g_object_unref (retval);
658 return NULL((void*)0);
659 }
660
661 return retval;
662}
663
664/**
665 * cdk_pixbuf_loader_new_with_mime_type:
666 * @mime_type: the mime type to be loaded
667 * @error: (allow-none): return location for an allocated #GError, or `NULL` to ignore errors
668 *
669 * Creates a new pixbuf loader object that always attempts to parse
670 * image data as if it were an image of MIME type @mime_type, instead of
671 * identifying the type automatically.
672 *
673 * This function is useful if you want an error if the image isn't the
674 * expected MIME type; for loading image formats that can't be reliably
675 * identified by looking at the data; or if the user manually forces a
676 * specific MIME type.
677 *
678 * The list of supported mime types depends on what image loaders
679 * are installed, but typically "image/png", "image/jpeg", "image/gif",
680 * "image/tiff" and "image/x-xpixmap" are among the supported mime types.
681 * To obtain the full list of supported mime types, call
682 * cdk_pixbuf_format_get_mime_types() on each of the #CdkPixbufFormat
683 * structs returned by cdk_pixbuf_get_formats().
684 *
685 * Return value: A newly-created pixbuf loader.
686 *
687 * Since: 2.4
688 **/
689CdkPixbufLoader *
690cdk_pixbuf_loader_new_with_mime_type (const char *mime_type,
691 GError **error)
692{
693 const char * image_type = NULL((void*)0);
694 char ** mimes;
695
696 CdkPixbufLoader *retval;
697 GError *tmp;
698
699 GSList * formats;
700 CdkPixbufFormat *info;
701 int i, j, length;
702
703 formats = cdk_pixbuf_get_formats ();
704 length = g_slist_length (formats);
705
706 for (i = 0; i < length && image_type == NULL((void*)0); i++) {
707 info = (CdkPixbufFormat *)g_slist_nth_data (formats, i);
708 mimes = info->mime_types;
709
710 for (j = 0; mimes[j] != NULL((void*)0); j++)
711 if (g_ascii_strcasecmp (mimes[j], mime_type) == 0) {
712 image_type = info->name;
713 break;
714 }
715 }
716
717 g_slist_free (formats);
718
719 retval = g_object_new (CDK_TYPE_PIXBUF_LOADER(cdk_pixbuf_loader_get_type ()), NULL((void*)0));
720
721 tmp = NULL((void*)0);
722 cdk_pixbuf_loader_load_module (retval, image_type, &tmp);
723 if (tmp != NULL((void*)0))
724 {
725 g_propagate_error (error, tmp);
726 cdk_pixbuf_loader_close (retval, NULL((void*)0));
727 g_object_unref (retval);
728 return NULL((void*)0);
729 }
730
731 return retval;
732}
733
734CdkPixbufLoader *
735_cdk_pixbuf_loader_new_with_filename (const char *filename)
736{
737 CdkPixbufLoader *retval;
738 CdkPixbufLoaderPrivate *priv;
739
740 retval = g_object_new (CDK_TYPE_PIXBUF_LOADER(cdk_pixbuf_loader_get_type ()), NULL((void*)0));
741 priv = retval->priv;
742 priv->filename = g_strdup (filename)g_strdup_inline (filename);
743
744 return retval;
745}
746
747/**
748 * cdk_pixbuf_loader_get_pixbuf:
749 * @loader: A pixbuf loader.
750 *
751 * Queries the #CdkPixbuf that a pixbuf loader is currently creating.
752 *
753 * In general it only makes sense to call this function after the
754 * [signal@CdkPixbuf.PixbufLoader::area-prepared] signal has been
755 * emitted by the loader; this means that enough data has been read
756 * to know the size of the image that will be allocated.
757 *
758 * If the loader has not received enough data via cdk_pixbuf_loader_write(),
759 * then this function returns `NULL`.
760 *
761 * The returned pixbuf will be the same in all future calls to the loader,
762 * so if you want to keep using it, you should acquire a reference to it.
763 *
764 * Additionally, if the loader is an animation, it will return the "static
765 * image" of the animation (see cdk_pixbuf_animation_get_static_image()).
766 *
767 * Return value: (transfer none) (nullable): The pixbuf that the loader is
768 * creating
769 **/
770CdkPixbuf *
771cdk_pixbuf_loader_get_pixbuf (CdkPixbufLoader *loader)
772{
773 CdkPixbufLoaderPrivate *priv;
774
775 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_39
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_39 = 1; _g_boolean_var_39; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return (((void*)0)); } }
while (0)
;
776
777 priv = loader->priv;
778
779G_GNUC_BEGIN_IGNORE_DEPRECATIONSclang diagnostic push clang diagnostic ignored "-Wdeprecated-declarations"
780 if (priv->animation)
781 return cdk_pixbuf_animation_get_static_image (priv->animation);
782 else
783 return NULL((void*)0);
784G_GNUC_END_IGNORE_DEPRECATIONSclang diagnostic pop
785}
786
787/**
788 * cdk_pixbuf_loader_get_animation:
789 * @loader: A pixbuf loader
790 *
791 * Queries the #CdkPixbufAnimation that a pixbuf loader is currently creating.
792 *
793 * In general it only makes sense to call this function after the
794 * [signal@CdkPixbuf.PixbufLoader::area-prepared] signal has been emitted by
795 * the loader.
796 *
797 * If the loader doesn't have enough bytes yet, and hasn't emitted the `area-prepared`
798 * signal, this function will return `NULL`.
799 *
800 * Return value: (transfer none) (nullable): The animation that the loader is
801 * currently loading
802 */
803CdkPixbufAnimation *
804cdk_pixbuf_loader_get_animation (CdkPixbufLoader *loader)
805{
806 CdkPixbufLoaderPrivate *priv;
807
808 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_40
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_40 = 1; _g_boolean_var_40; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return (((void*)0)); } }
while (0)
;
809
810 priv = loader->priv;
811
812 return priv->animation;
813}
814
815/**
816 * cdk_pixbuf_loader_close:
817 * @loader: A pixbuf loader.
818 * @error: (allow-none): return location for a #GError, or `NULL` to ignore errors
819 *
820 * Informs a pixbuf loader that no further writes with
821 * cdk_pixbuf_loader_write() will occur, so that it can free its
822 * internal loading structures.
823 *
824 * This function also tries to parse any data that hasn't yet been parsed;
825 * if the remaining data is partial or corrupt, an error will be returned.
826 *
827 * If `FALSE` is returned, `error` will be set to an error from the
828 * `CDK_PIXBUF_ERROR` or `G_FILE_ERROR` domains.
829 *
830 * If you're just cancelling a load rather than expecting it to be finished,
831 * passing `NULL` for `error` to ignore it is reasonable.
832 *
833 * Remember that this function does not release a reference on the loader, so
834 * you will need to explicitly release any reference you hold.
835 *
836 * Returns: `TRUE` if all image data written so far was successfully
837 * passed out via the update_area signal
838 */
839gboolean
840cdk_pixbuf_loader_close (CdkPixbufLoader *loader,
841 GError **error)
842{
843 CdkPixbufLoaderPrivate *priv;
844 gboolean retval = TRUE(!(0));
845
846 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), TRUE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_41
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_41 = 1; _g_boolean_var_41; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return ((!(0))); } } while
(0)
;
847 g_return_val_if_fail (error == NULL || *error == NULL, TRUE)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_42
= 0; if (error == ((void*)0) || *error == ((void*)0)) _g_boolean_var_42
= 1; _g_boolean_var_42; }), 1))) { } else { g_return_if_fail_warning
("CdkPixbuf", ((const char*) (__func__)), "error == NULL || *error == NULL"
); return ((!(0))); } } while (0)
;
848
849 priv = loader->priv;
850
851 if (priv->closed)
852 return TRUE(!(0));
853
854 /* We have less than SNIFF_BUFFER_SIZE bytes in the image.
855 * Flush it, and keep going.
856 */
857 if (priv->image_module == NULL((void*)0))
858 {
859 GError *tmp = NULL((void*)0);
860 cdk_pixbuf_loader_load_module (loader, NULL((void*)0), &tmp);
861 if (tmp != NULL((void*)0))
862 {
863 g_propagate_error (error, tmp);
864 retval = FALSE(0);
865 }
866 }
867
868 if (priv->image_module && priv->image_module->stop_load && priv->context)
869 {
870 GError *tmp = NULL((void*)0);
871 if (!priv->image_module->stop_load (priv->context, &tmp) || tmp)
872 {
873 /* don't call cdk_pixbuf_loader_ensure_error()
874 * here, since we might not get an error in the
875 * cdk_pixbuf_get_file_info() case
876 */
877 if (tmp) {
878 if (error && *error == NULL((void*)0))
879 g_propagate_error (error, tmp);
880 else
881 g_error_free (tmp);
882 }
883 retval = FALSE(0);
884 }
885 }
886
887 priv->closed = TRUE(!(0));
888
889 if (priv->needs_scale)
890 {
891
892 g_signal_emit (loader, pixbuf_loader_signals[AREA_PREPARED], 0);
893 g_signal_emit (loader, pixbuf_loader_signals[AREA_UPDATED], 0,
894 0, 0, priv->width, priv->height);
895 }
896
897
898 g_signal_emit (loader, pixbuf_loader_signals[CLOSED], 0);
899
900 return retval;
901}
902
903/**
904 * cdk_pixbuf_loader_get_format:
905 * @loader: A pixbuf loader.
906 *
907 * Obtains the available information about the format of the
908 * currently loading image file.
909 *
910 * Returns: (nullable) (transfer none): A #CdkPixbufFormat
911 *
912 * Since: 2.2
913 */
914CdkPixbufFormat *
915cdk_pixbuf_loader_get_format (CdkPixbufLoader *loader)
916{
917 CdkPixbufLoaderPrivate *priv;
918
919 g_return_val_if_fail (CDK_IS_PIXBUF_LOADER (loader), NULL)do { if ((__builtin_expect (__extension__ ({ int _g_boolean_var_43
= 0; if ((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((loader)); GType __t = ((cdk_pixbuf_loader_get_type ()));
gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class
&& __inst->g_class->g_type == __t) __r = (!(0)
); else __r = g_type_check_instance_is_a (__inst, __t); __r; }
))))) _g_boolean_var_43 = 1; _g_boolean_var_43; }), 1))) { } else
{ g_return_if_fail_warning ("CdkPixbuf", ((const char*) (__func__
)), "CDK_IS_PIXBUF_LOADER (loader)"); return (((void*)0)); } }
while (0)
;
920
921 priv = loader->priv;
922
923 if (priv->image_module)
924 return _cdk_pixbuf_get_format (priv->image_module);
925 else
926 return NULL((void*)0);
927}