diff options
author | Robert Tari <robert@tari.in> | 2025-02-06 13:09:34 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2025-03-12 08:54:21 +0100 |
commit | 227aa4bc0f094e6168980e83542a7460523e0f51 (patch) | |
tree | f4175441b93f355b88f41cf6b8a524eb19907224 /tests/test-timezones.cpp | |
parent | e87e66518761d407e18461dd942e94989bb3b2ac (diff) | |
download | ayatana-indicator-datetime-227aa4bc0f094e6168980e83542a7460523e0f51.tar.gz ayatana-indicator-datetime-227aa4bc0f094e6168980e83542a7460523e0f51.tar.bz2 ayatana-indicator-datetime-227aa4bc0f094e6168980e83542a7460523e0f51.zip |
tests/test-timezones.cpp: Avoid potential null pointer
Diffstat (limited to 'tests/test-timezones.cpp')
-rw-r--r-- | tests/test-timezones.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/tests/test-timezones.cpp b/tests/test-timezones.cpp index 7144aaf..1cbab16 100644 --- a/tests/test-timezones.cpp +++ b/tests/test-timezones.cpp @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2025 Robert Tari * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License version 3, as published @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include "geoclue-fixture.h" @@ -39,9 +41,13 @@ namespace void set_file(const std::string& text) { auto fp = fopen(TIMEZONE_FILE, "w+"); - fprintf(fp, "%s\n", text.c_str()); - fclose(fp); - sync(); + + if (fp) + { + fprintf(fp, "%s\n", text.c_str()); + fclose(fp); + sync(); + } } } |