From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Warning in svg_load_image Date: Tue, 22 Feb 2022 14:32:59 +0200 Message-ID: <83sfsbt72c.fsf@gnu.org> References: <87ilt8hcz4.fsf.ref@yahoo.com> <87ilt8hcz4.fsf@yahoo.com> <83r17wuz9s.fsf@gnu.org> <87y224e3x3.fsf@yahoo.com> <83pmnguy3w.fsf@gnu.org> <877d9nd0bg.fsf@yahoo.com> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31524"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Po Lu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Feb 22 13:36:32 2022 Return-path: Envelope-to: ged-emacs-devel@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 1nMUPA-00083b-8t for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Feb 2022 13:36:32 +0100 Original-Received: from localhost ([::1]:52746 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nMUP8-0001qa-UP for ged-emacs-devel@m.gmane-mx.org; Tue, 22 Feb 2022 07:36:30 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMULt-0007Fa-0p for emacs-devel@gnu.org; Tue, 22 Feb 2022 07:33:10 -0500 Original-Received: from [2001:470:142:3::e] (port=46188 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMULm-0004U0-Sc; Tue, 22 Feb 2022 07:33:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=VyCbBEXbpD3IWKwwzgksiHvc72xV9tvj2DDIGNeB5uQ=; b=fcN6hjDVzjqh OmUoQIgF3eve0i2gfzwVIX3xkkqi8jkasM40sj4cRmTs7ljNv5/qhK7UcWD9Cw1GN/0HEAx1mZHZv ROAzE1nT8nu8qZpM/OCZk7Kd7OZDEJJX4k/m4HT07fske4zXIOqaGBKOZQvDuGmSujmtnP2GPR3be biFsxlSyBTbU7WVf9GeEQgBaOyA6XcgvEk/972vjeGwKlutbUlhK8OCXHDtJtO7bkJ3aodb0iaFIi ypF4gsTLf9munTRYhWmdbOdBMglSa9GF/vrTSD5prfwFgvV2Hl8JmUanxC9aFOuzKF9eo7dJeX5oH jhNvoJ9qWY2svBir19cqkg==; Original-Received: from [87.69.77.57] (port=1308 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nMULb-0001At-8h; Tue, 22 Feb 2022 07:32:56 -0500 In-Reply-To: <877d9nd0bg.fsf@yahoo.com> (message from Po Lu on Tue, 22 Feb 2022 11:53:07 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:286586 Archived-At: > From: Po Lu > Cc: emacs-devel@gnu.org > Date: Tue, 22 Feb 2022 11:53:07 +0800 > > Eli Zaretskii writes: > > > What about the one below: > > That also gives another warning: Sigh. Last chance: diff --git a/src/image.c b/src/image.c index e2ba744..eb16a3f 100644 --- a/src/image.c +++ b/src/image.c @@ -10632,9 +10632,9 @@ svg_load_image (struct frame *f, struct image *img, char *contents, strncpy (css, SSDATA (lcss), SBYTES (lcss)); *(css + SBYTES (lcss) + 1) = 0; } -#endif +#endif /* LIBRSVG >= 2.48.0 */ -#else +#else /* LIBRSVG < 2.32.0 */ /* Make a handle to a new rsvg object. */ rsvg_handle = rsvg_handle_new (); eassume (rsvg_handle); @@ -10657,7 +10657,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, it for further writes. */ rsvg_handle_close (rsvg_handle, &err); if (err) goto rsvg_error; -#endif +#endif /* LIBRSVG 2.32.0 */ /* Get the image dimensions. */ #if LIBRSVG_CHECK_VERSION (2, 46, 0) @@ -10727,13 +10727,13 @@ svg_load_image (struct frame *f, struct image *img, char *contents, viewbox_height = viewbox.y + viewbox.height; } } -#else +#else /* LIBRSVG < 2.46.0 */ /* In librsvg before 2.46.0, guess the viewbox from the image dimensions. */ RsvgDimensionData dimension_data; rsvg_handle_get_dimensions (rsvg_handle, &dimension_data); viewbox_width = dimension_data.width; viewbox_height = dimension_data.height; -#endif +#endif /* LIBRSVG < 2.46.0 */ #ifdef HAVE_NATIVE_TRANSFORMS compute_image_size (viewbox_width, viewbox_height, img, @@ -10777,7 +10777,7 @@ svg_load_image (struct frame *f, struct image *img, char *contents, "xmlns:xi=\"http://www.w3.org/2001/XInclude\" " "style=\"color: #%06X; fill: currentColor;\" " "width=\"%d\" height=\"%d\" preserveAspectRatio=\"none\" " - "viewBox=\"0 0 %f %f\">" + "viewBox=\"0 0 %5.0f %5.0f\">" "" "" ""; @@ -10801,7 +10801,9 @@ svg_load_image (struct frame *f, struct image *img, char *contents, if (buffer_size <= snprintf (wrapped_contents, buffer_size, wrapper, foreground & 0xFFFFFF, width, height, - viewbox_width, viewbox_height, + /* Sanitize the viewBox dimensions. */ + min (max (viewbox_width, 1.), 10000.), + min (max (viewbox_height, 1.), 10000.), background & 0xFFFFFF, SSDATA (encoded_contents))) goto rsvg_error;