]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-lua/dlua-iostream: dlua_i_read_common() - Optimize error handling
authorKarl Fleischmann <karl.fleischmann@open-xchange.com>
Wed, 21 May 2025 09:42:16 +0000 (11:42 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 22 May 2025 11:24:01 +0000 (11:24 +0000)
This also makes the error handling more explicit.

src/lib-lua/dlua-iostream.c

index af1e0a628716f933488649105b7ef229a97bda6d..2b1bb2caa1b4e3d156a31e931f474391369671d2 100644 (file)
@@ -189,9 +189,12 @@ static int dlua_i_read_common(lua_State *L, struct dlua_iostream *stream, int fi
        int nargs = lua_gettop(L) - 1;
        bool success;
        int n;
-       (void)i_stream_read(stream->is);
 
-       if (nargs == 0) {
+       if (i_stream_read(stream->is) < 0 &&
+           stream->is->stream_errno != 0) {
+               /* Skip to error handling. */
+               success = FALSE;
+       } else if (nargs == 0) {
                success = dlua_read_line(L, stream, TRUE);
                n = first + 1;
        } else {