[seahorse/gnome-3-30] Use string.data to convert a string to a uint8[]



commit 07120b25e6db010c7449764ffe147c3c23404343
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Tue Dec 11 12:15:46 2018 +0100

    Use string.data to convert a string to a uint8[]
    
    Otherwise, vala will pass on an array length of -1, which can crash in
    some cases (such as `Bytes.new()`).
    
    Fixes https://gitlab.gnome.org/GNOME/seahorse/issues/206.

 common/key-manager-store.vala | 4 ++--
 src/import-dialog.vala        | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
---
diff --git a/common/key-manager-store.vala b/common/key-manager-store.vala
index 404d8fd2..16a811ae 100644
--- a/common/key-manager-store.vala
+++ b/common/key-manager-store.vala
@@ -333,7 +333,7 @@ public class Seahorse.KeyManagerStore : Gcr.CollectionModel {
         if (this.drag_objects != null) {
             Gdk.Window? source_window = context.get_source_window();
             Gdk.property_change (source_window, XDS_ATOM, TEXT_ATOM, 8, Gdk.PropMode.REPLACE,
-                                 (uint8[]) XDS_FILENAME, XDS_FILENAME.length);
+                                 XDS_FILENAME.data, XDS_FILENAME.length);
         }
 
         debug("drag_begin <--");
@@ -398,7 +398,7 @@ public class Seahorse.KeyManagerStore : Gcr.CollectionModel {
                     return;
                 this.drag_destination = Path.get_dirname (destination);
 
-                selection_data.set(selection_data.get_target(), 8, (uint8[]) "S");
+                selection_data.set(selection_data.get_target(), 8, "S".data);
             }
 
         // Unrecognized format
diff --git a/src/import-dialog.vala b/src/import-dialog.vala
index eda6bce7..a99dd191 100644
--- a/src/import-dialog.vala
+++ b/src/import-dialog.vala
@@ -55,7 +55,7 @@ public class Seahorse.ImportDialog : Gtk.Dialog {
     }
 
     public void add_text(string? display_name, string text) {
-        this.viewer.load_data(display_name, (uint8[]) text);
+        this.viewer.load_data(display_name, text.data);
     }
 
     private void on_import_button_imported(GLib.Object importer, Error? error) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]