summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/util.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/util.rs b/src/util.rs
index 54062a5..567c478 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -83,10 +83,13 @@ pub fn result_from_string(ptr: *const c_char) -> Result<String, CommandError> {
unsafe {
let s = owned_str_from_ptr(ptr);
free(ptr as *mut c_void);
+ // An empty string can both indicate an error or be a valid return value. In this case, we
+ // have to check the last command status to decide what to return.
if s.is_empty() {
- return Err(get_last_error());
+ get_last_result().map(|_| s)
+ } else {
+ Ok(s)
}
- return Ok(s);
}
}