]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: (filter) check vasprintf() return value
authorKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 10:53:46 +0000 (12:53 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 15 Apr 2024 10:53:51 +0000 (12:53 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/filter-parser.y

index 9104c5e0620476816d68a3622071bbab7bfe74da..c368c952c23ff821663310f3c7d11d604b62427d 100644 (file)
@@ -124,6 +124,7 @@ void yyerror (yyscan_t *locp __attribute__((__unused__)),
        if (fmt && fltr) {
                char *p;
                va_list ap;
+               int e;
 
                if (fltr->errmsg) {
                        free(fltr->errmsg);
@@ -131,10 +132,10 @@ void yyerror (yyscan_t *locp __attribute__((__unused__)),
                }
 
                va_start(ap, fmt);
-               vasprintf(&fltr->errmsg, fmt, ap);
+               e = vasprintf(&fltr->errmsg, fmt, ap);
                va_end(ap);
 
-               if (!fltr->errmsg)
+               if (e < 0 || !fltr->errmsg)
                        return;
 
                p = strstr(fltr->errmsg, "T_");