]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
json: move empty string check from json_parse_file_at() to json_parse_with_source()
authorLennart Poettering <lennart@poettering.net>
Mon, 27 May 2024 09:36:48 +0000 (11:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 13 Jun 2024 09:30:12 +0000 (11:30 +0200)
That way this error is generalized and applies to either function, since
one is just a wrapper to the other, normalizing behaviour.

src/libsystemd/sd-json/sd-json.c

index 3a0b838c513e5bbd86cd705ced30fa9c440ccb20..2c5c0a35c9420f713e043df0df8c6fa62815afc7 100644 (file)
@@ -3378,6 +3378,9 @@ _public_ int sd_json_parse_with_source(
 
         _cleanup_(json_source_unrefp) JsonSource *s = NULL;
 
+        if (isempty(input))
+                return -ENODATA;
+
         if (source) {
                 s = json_source_new(source);
                 if (!s)
@@ -3447,9 +3450,6 @@ _public_ int sd_json_parse_file_at(
         if (r < 0)
                 return r;
 
-        if (isempty(text))
-                return -ENODATA;
-
         return sd_json_parse_with_source(text, path, flags, ret, reterr_line, reterr_column);
 }