From 741ef60a24193ef18ae688eb2034347260e9d78c Mon Sep 17 00:00:00 2001 From: Fenrir Date: Sun, 29 Apr 2018 17:31:52 -0600 Subject: [PATCH] Add nul-terminatator to input that expects it --- ctru-rs/src/applets/swkbd.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index ee6d99a..515dd92 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -1,3 +1,4 @@ +use std::iter::once; use std::mem; use std::str; @@ -160,7 +161,8 @@ impl Swkbd { /// when the textbox is empty) pub fn set_hint_text(&mut self, text: &str) { unsafe { - swkbdSetHintText(self.state.as_mut(), text.as_ptr()); + let nul_terminated: String = text.chars().chain(once('\0')).collect(); + swkbdSetHintText(self.state.as_mut(), nul_terminated.as_ptr()); } } @@ -172,7 +174,8 @@ impl Swkbd { /// discard it. pub fn configure_button(&mut self, button: Button, text: &str, submit: bool) { unsafe { - swkbdSetButton(self.state.as_mut(), button as u32, text.as_ptr(), submit); + let nul_terminated: String = text.chars().chain(once('\0')).collect(); + swkbdSetButton(self.state.as_mut(), button as u32, nul_terminated.as_ptr(), submit); } }