From: Lennart Poettering Date: Mon, 27 May 2024 09:36:48 +0000 (+0200) Subject: json: move empty string check from json_parse_file_at() to json_parse_with_source() X-Git-Tag: v257-rc1~1166^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aacbc2acb94d95ccedb69cc1bcabc31833d48aa2;p=thirdparty%2Fsystemd.git 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. --- 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); }