]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
charts: Fix error handling if gvRenderData() returns an error
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Wed, 13 May 2015 16:40:59 +0000 (18:40 +0200)
committerFlorian Brosch <flo.brosch@gmail.com>
Sun, 10 Jan 2016 20:55:25 +0000 (21:55 +0100)
If libgvc was not built properly or is running against incorrectly versioned
plugins, gvRenderData() can fail and return a null string. Ensure libvaladoc
handles this correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=711590

src/libvaladoc/charts/chart.vala
src/libvaladoc/html/htmlmarkupwriter.vala

index 03dab30f7536d6a8a35b055d5482ee9d2d93e860..a6307d7ffe6d7da67d87f72f0f3b3ea57a53b5c1 100644 (file)
@@ -52,13 +52,14 @@ public class Valadoc.Charts.Chart : Api.Visitor {
                context.render (graph, file_type, file);
        }
 
-       public uint8[] write_buffer (string file_type) {
+       public uint8[]? write_buffer (string file_type) {
                if (context == null) {
                        context = factory.create_context (graph);
                }
 
-               uint8[] data;
+               uint8[]? data;
 
+               /* This will return null in data if it fails. */
                context.render_data (graph, file_type, out data);
                return data;
        }
index 113f0c6f1af6387d7f19fea56255a570a83c6e25..15ed9efd175c5723447d4b6ccec22507672a5e54 100644 (file)
@@ -44,9 +44,11 @@ public class Valadoc.Html.MarkupWriter : Valadoc.MarkupWriter {
        }
 
        public MarkupWriter add_usemap (Charts.Chart chart) {
-               string buf = (string) chart.write_buffer ("cmapx");
-               raw_text ("\n");
-               raw_text (buf);
+               string? buf = (string?) chart.write_buffer ("cmapx");
+               if (buf != null) {
+                       raw_text ("\n");
+                       raw_text ((!) buf);
+               }
 
                return this;
        }