From aacbc2acb94d95ccedb69cc1bcabc31833d48aa2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 27 May 2024 11:36:48 +0200 Subject: [PATCH] json: move empty string check from json_parse_file_at() to json_parse_with_source() 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 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsystemd/sd-json/sd-json.c b/src/libsystemd/sd-json/sd-json.c index 3a0b838c513..2c5c0a35c94 100644 --- a/src/libsystemd/sd-json/sd-json.c +++ b/src/libsystemd/sd-json/sd-json.c @@ -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); } -- 2.47.3