From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: dick Newsgroups: gmane.emacs.bugs Subject: bug#57755: 29.0.50; [PATCH] Fallout 816106b Date: Mon, 12 Sep 2022 17:16:02 -0400 Message-ID: <87bkrki99p.fsf@dick> References: <87edwgib1y.fsf@dick> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9959"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.14 (Gnus v5.14) Commercial/29.0.50 (gnu/linux) To: 57755@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Sep 13 09:32:58 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oY0Pg-0002NC-Jw for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Sep 2022 09:32:56 +0200 Original-Received: from localhost ([::1]:35190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oY0Pe-0002gq-II for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 13 Sep 2022 03:32:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oY0Ky-0007Fv-6C for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 03:28:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:59962) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oY0Kx-0002Ss-00 for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 03:28:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1oY0Kw-0000NL-Rs for bug-gnu-emacs@gnu.org; Tue, 13 Sep 2022 03:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: dick Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 13 Sep 2022 07:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 57755 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 57755-submit@debbugs.gnu.org id=B57755.16630540571383 (code B ref 57755); Tue, 13 Sep 2022 07:28:02 +0000 Original-Received: (at 57755) by debbugs.gnu.org; 13 Sep 2022 07:27:37 +0000 Original-Received: from localhost ([127.0.0.1]:48656 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oY0KW-0000MD-Eg for submit@debbugs.gnu.org; Tue, 13 Sep 2022 03:27:37 -0400 Original-Received: from mail-qt1-f172.google.com ([209.85.160.172]:39674) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1oXqmn-0003P7-OR for 57755@debbugs.gnu.org; Mon, 12 Sep 2022 17:16:12 -0400 Original-Received: by mail-qt1-f172.google.com with SMTP id s18so4290544qtx.6 for <57755@debbugs.gnu.org>; Mon, 12 Sep 2022 14:16:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:from:to:cc:subject:date; bh=kcZTH8aUAPPspLLutaHIXeV/xE3YbWl2+WuJsJU8d9E=; b=RFUeF9Ups73Q9sSEvOtO0opZi7h8R72OV74SfHqeYmdPBulhrgPC2SEOkHar8OGCxo CZxgWZnImvRag2B1vO825i2W+DWypBopaV8oP8xFKHv7oqCvWC8I033yA8QSq1dvCvSd FfePSm/lEHF9+2Ms3HhA9Bdmy2TR4xyorwo1mQO4s1swMvmP8Jvgp+CJJDj4EZaD7Nng zeq+MTqzm0LLWQRQABIohGngjKZR4zK6QGTdEaf9HXXnckL34wkW0lejbbLvIAFOI1f1 lDRX343P3c5jMS4ofY2bnWcWmqWgVZfPcxhBw+WJNJH8vDagV5JbCiJjLyuFK06qo+3q Tctw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:x-gm-message-state:from:to:cc:subject:date; bh=kcZTH8aUAPPspLLutaHIXeV/xE3YbWl2+WuJsJU8d9E=; b=odFkZ9M0pY6KVn5m94ANYpU0XEjcc85KW7qQPJ97pE7IfSY8cPMeUzZHkk17kC3ZtX G5BlRXxbHZ5jjBw1WG+hfFdGG4O6N/Q3klJFxFl7u8nW773UW4+8kNATCgO01pfCh4KV HJi8AO1PhT+7+qiBv777ueP7P0uAF/VT5oFkcaz/PIBw8Ntdlkk7xEJOQw8RrD2LGgqs UuQ0az35PKOiA4tq3f4sqoofhhjtdEbmqITrF96s4fGw8jAX09E0fBKkpnn+HN4fLgI2 ncB+AzsAh+/Sfu2jqczC8cr7lcvsT8xtKCE6qoidVk1WQFBSMsfllCunJPYvueVkt/sx cx3g== X-Gm-Message-State: ACgBeo1u5JkbJFVgJW+x3aidtNkP6LzGqLaDJLCYgHrMptJv7CD+sNXw iYRR28cKviAOWtSzdNX3Cf0isoT3Mn0= X-Google-Smtp-Source: AA6agR4M0suXKehdA+6H5R4cxsAzel0DrMqgtuGx5RfI6e4JcKIPNVKbPnhOIlLPZdRGA6cc04+khg== X-Received: by 2002:a05:622a:4204:b0:344:e16c:e597 with SMTP id cp4-20020a05622a420400b00344e16ce597mr25480861qtb.592.1663017363892; Mon, 12 Sep 2022 14:16:03 -0700 (PDT) Original-Received: from localhost (pool-173-56-234-28.nycmny.fios.verizon.net. [173.56.234.28]) by smtp.gmail.com with ESMTPSA id t12-20020a37ea0c000000b006bc6aef46basm8194587qkj.114.2022.09.12.14.16.02 for <57755@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 14:16:03 -0700 (PDT) In-Reply-To: <87edwgib1y.fsf@dick> (dick's message of "Mon, 12 Sep 2022 16:37:29 -0400") X-Mailman-Approved-At: Tue, 13 Sep 2022 03:27:35 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:242328 Archived-At: --=-=-= Content-Type: text/plain Oh right, ming wong32. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Fallout-816106b.patch >From 644482da6e69c38b75b461c13a9eb404e014ca78 Mon Sep 17 00:00:00 2001 From: dickmao Date: Mon, 12 Sep 2022 17:08:09 -0400 Subject: [PATCH] Fallout 816106b * src/image.c (init_svg_functions, g_clear_error): Disregard youthful indiscretions Bug#21641. (svg_load_image): Avoid segfault and double reporting errors. * test/manual/image-tests.el (image-tests-load-image/svg-too-big, image-tests-load-image/svg-invalid): Test it. --- src/image.c | 26 +++++++++++++++++--------- test/manual/image-tests.el | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/image.c b/src/image.c index 549fe30ef7c..87ddb19b37e 100644 --- a/src/image.c +++ b/src/image.c @@ -10907,7 +10907,7 @@ DEF_DLL_FN (int, gdk_pixbuf_get_bits_per_sample, (const GdkPixbuf *)); DEF_DLL_FN (void, g_type_init, (void)); # endif DEF_DLL_FN (void, g_object_unref, (gpointer)); -DEF_DLL_FN (void, g_clear_error, (GError **)); +DEF_DLL_FN (void, g_error_free, (GError *)); static bool init_svg_functions (void) @@ -10967,7 +10967,7 @@ init_svg_functions (void) LOAD_DLL_FN (gobject, g_type_init); # endif LOAD_DLL_FN (gobject, g_object_unref); - LOAD_DLL_FN (glib, g_clear_error); + LOAD_DLL_FN (glib, g_error_free); return 1; } @@ -10983,7 +10983,7 @@ init_svg_functions (void) # undef gdk_pixbuf_get_pixels # undef gdk_pixbuf_get_rowstride # undef gdk_pixbuf_get_width -# undef g_clear_error +# undef g_error_free # undef g_object_unref # undef g_type_init # if LIBRSVG_CHECK_VERSION (2, 52, 1) @@ -11019,7 +11019,7 @@ init_svg_functions (void) # define gdk_pixbuf_get_pixels fn_gdk_pixbuf_get_pixels # define gdk_pixbuf_get_rowstride fn_gdk_pixbuf_get_rowstride # define gdk_pixbuf_get_width fn_gdk_pixbuf_get_width -# define g_clear_error fn_g_clear_error +# define g_error_free fn_g_error_free # define g_object_unref fn_g_object_unref # if ! GLIB_CHECK_VERSION (2, 36, 0) # define g_type_init fn_g_type_init @@ -11353,7 +11353,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, if (! check_image_size (f, width, height)) { image_size_error (); - goto rsvg_error; + goto done_error; } /* We are now done with the unmodified data. */ @@ -11536,9 +11536,21 @@ svg_load_image (struct frame *f, struct image *img, char *contents, image_put_x_image (f, img, ximg, 0); } + eassume (err == NULL); return true; rsvg_error: + if (err == NULL) + image_error ("Error parsing SVG image"); + else + { + image_error ("Error parsing SVG image: %s", + call2 (intern ("string-trim-right"), build_string (err->message), + Qnil)); + g_error_free (err); + } + + done_error: if (rsvg_handle) g_object_unref (rsvg_handle); if (wrapped_contents) @@ -11547,10 +11559,6 @@ svg_load_image (struct frame *f, struct image *img, char *contents, if (css && !STRINGP (lcss)) xfree (css); #endif - image_error ("Error parsing SVG image: %s", - /* The -1 removes an extra newline. */ - make_string (err->message, strlen (err->message) - 1)); - g_clear_error (&err); return false; } diff --git a/test/manual/image-tests.el b/test/manual/image-tests.el index f867047d08e..76a22c25718 100644 --- a/test/manual/image-tests.el +++ b/test/manual/image-tests.el @@ -79,6 +79,21 @@ image-tests-make-load-image-test (image-tests-make-load-image-test 'xbm) (image-tests-make-load-image-test 'xpm) +(ert-deftest image-tests-load-image/svg-too-big () + (with-temp-buffer + (let* ((max-image-size 0) + (messages-buffer-name (buffer-name (current-buffer))) + (img (cdr (assq 'svg image-tests--images))) + (file (if (listp img) + (plist-get (cdr img) :file) + img))) + (save-excursion (find-file file)) + (should (string-match-p "invalid image size" (buffer-string))) + ;; no annoying newlines + (should-not (string-match-p "^[ \t\n\r]+$" (buffer-string))) + ;; no annoying double error reporting + (should-not (string-match-p "error parsing" (buffer-string)))))) + (ert-deftest image-tests-load-image/svg-invalid () (with-temp-buffer (let ((messages-buffer-name (buffer-name (current-buffer)))) @@ -90,7 +105,9 @@ image-tests-load-image/svg-invalid :type svg))) (redisplay)) ;; librsvg error: "... Start tag expected, '<' not found [3 times]" - (should (string-match "[Ee]rror.+Start tag expected" (buffer-string)))))) + (should (string-match-p "[Ee]rror.+Start tag expected" (buffer-string))) + ;; no annoying newlines + (should-not (string-match-p "^[ \t\n\r]+$" (buffer-string)))))) ;;;; image-test-size -- 2.36.1 --=-=-=--