]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal: use free_and_strdup() where appropriate
authorLennart Poettering <lennart@poettering.net>
Tue, 8 Jun 2021 20:15:15 +0000 (22:15 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 9 Jun 2021 07:34:50 +0000 (09:34 +0200)
src/libsystemd/sd-journal/sd-journal.c

index 35834d97a1582ee9100571c208bf62f99ebe500e..aab620c96ee6de43ead4baf28702ceb759af8bc0 100644 (file)
@@ -2867,19 +2867,17 @@ _public_ int sd_journal_get_usage(sd_journal *j, uint64_t *ret) {
 }
 
 _public_ int sd_journal_query_unique(sd_journal *j, const char *field) {
-        char *f;
+        int r;
 
         assert_return(j, -EINVAL);
         assert_return(!journal_pid_changed(j), -ECHILD);
         assert_return(!isempty(field), -EINVAL);
         assert_return(field_is_valid(field), -EINVAL);
 
-        f = strdup(field);
-        if (!f)
-                return -ENOMEM;
+        r = free_and_strdup(&j->unique_field, field);
+        if (r < 0)
+                return r;
 
-        free(j->unique_field);
-        j->unique_field = f;
         j->unique_file = NULL;
         j->unique_offset = 0;
         j->unique_file_lost = false;