Bug Summary

File:tests/libebook/vcard/dump-vcard.c
Warning:line 31, column 7
File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -O3 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name dump-vcard.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 -pic-is-pie -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=/builds/GNOME/evolution-data-server/_build -fcoverage-compilation-dir=/builds/GNOME/evolution-data-server/_build -resource-dir /usr/bin/../lib/clang/22 -D GLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_68 -D GLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_68 -D G_LOG_DOMAIN="dump-vcard" -D LDAP_DEPRECATED -D SOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_3_2 -D SOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_3_2 -D _LARGEFILE64_SOURCE=1 -I /builds/GNOME/evolution-data-server/_build -I /builds/GNOME/evolution-data-server/_build/src -I /builds/GNOME/evolution-data-server/_build/src/addressbook -I /builds/GNOME/evolution-data-server/src -I /builds/GNOME/evolution-data-server/src/addressbook -I /usr/include/libsoup-3.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libxml2 -I /usr/include/libsecret-1 -I /usr/include/gio-unix-2.0 -I /usr/include/p11-kit-1 -I /usr/include/nss3 -I /usr/include/nspr4 -I /home/user/_prefix/include -I /builds/GNOME/evolution-data-server/_build/src/private -I /builds/GNOME/evolution-data-server/src/private -I /builds/GNOME/evolution-data-server/_build/src/addressbook/libebook -I /builds/GNOME/evolution-data-server/src/addressbook/libebook -I /builds/GNOME/evolution-data-server/_build/src/camel -I /builds/GNOME/evolution-data-server/src/camel -I /builds/GNOME/evolution-data-server/_build/src/libebackend -I /builds/GNOME/evolution-data-server/src/libebackend -I /builds/GNOME/evolution-data-server/_build/src/libedataserver -I /builds/GNOME/evolution-data-server/src/libedataserver -I /usr/include/json-glib-1.0 -I /usr/include/uuid -I /builds/GNOME/evolution-data-server/_build/src/addressbook/libebook-contacts -I /builds/GNOME/evolution-data-server/src/addressbook/libebook-contacts -I /builds/GNOME/evolution-data-server/_build/src/addressbook/libedata-book -D NDEBUG -I /usr/include -I /usr/include/libsoup-3.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/sysprof-6 -I /usr/include/libxml2 -D WITH_GZFILEOP -I /usr/include/libsecret-1 -I /usr/include/gio-unix-2.0 -I /usr/include/p11-kit-1 -I /usr/include/nss3 -I /usr/include/nspr4 -D I18N_PHONENUMBERS_USE_BOOST -I /usr/include/json-glib-1.0 -I /usr/include/uuid -internal-isystem /usr/bin/../lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/16/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -Wno-sign-compare -Wno-missing-field-initializers -Wno-missing-include-dirs -Wno-deprecated-declarations -Wno-cast-function-type -Wwrite-strings -fconst-strings -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /builds/GNOME/evolution-data-server/_build/scan-build/2026-08-11-054813-10-1 -x c /builds/GNOME/evolution-data-server/tests/libebook/vcard/dump-vcard.c
1/*
2 * SPDX-License-Identifier: LGPL-2.0-or-later
3 */
4
5#include <stdio.h>
6#include <libebook-contacts/libebook-contacts.h>
7
8gint
9main (gint argc,
10 gchar **argv)
11{
12 FILE *fp;
13 EVCard *vcard;
14 GString *str;
15 gchar *parsed_vcard;
16
17 if (argc < 2) {
1
Assuming 'argc' is >= 2
2
Taking false branch
18 g_warning ("Requires one parameter, a vCard file\n");
19 return 1;
20 }
21
22 fp = fopen (argv[1], "r");
23 if (fp
2.1
'fp' is not equal to NULL
== NULL((void*)0)) {
3
Taking false branch
24 g_warning ("Faile to open vCard file '%s'", argv[1]);
25 return 1;
26 }
27
28 str = g_string_new ("");
29 while (!feof (fp)) {
4
Loop condition is true. Entering loop body
7
Loop condition is true. Entering loop body
30 gchar buf[1024];
31 if (fgets (buf, sizeof (buf), fp))
5
Assuming this stream operation fails
6
Taking false branch
8
File position of the stream might be 'indeterminate' after a failed operation. Can cause undefined behavior
32 g_string_append (str, buf)(__builtin_constant_p (buf) ? __extension__ ({ const char * const
__val = (buf); g_string_append_len_inline (str, __val, (__builtin_expect
(__extension__ ({ int _g_boolean_var_11 = 0; if (__val != ((
void*)0)) _g_boolean_var_11 = 1; _g_boolean_var_11; }), 1)) ?
(gssize) strlen (((__val) + !(__val))) : (gssize) -1); }) : g_string_append_len_inline
(str, buf, (gssize) -1))
;
33 }
34 fclose (fp);
35
36 vcard = e_vcard_new_from_string (str->str);
37 g_string_free (str, TRUE(!(0)));
38
39 e_vcard_dump_structure (vcard);
40
41 parsed_vcard = e_vcard_convert_to_string (vcard, E_VCARD_VERSION_21);
42 printf ("\nvCard 2.1: %s\n", parsed_vcard);
43 g_free (parsed_vcard);
44
45 parsed_vcard = e_vcard_convert_to_string (vcard, E_VCARD_VERSION_30);
46 printf ("\nvCard 3.0: %s\n", parsed_vcard);
47 g_free (parsed_vcard);
48
49 parsed_vcard = e_vcard_convert_to_string (vcard, E_VCARD_VERSION_40);
50 printf ("\nvCard 4.0: %s\n", parsed_vcard);
51 g_free (parsed_vcard);
52
53 g_object_unref (vcard);
54
55 return 0;
56}