Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 2204a60

Browse files
authored
Merge pull request #51 from RedBeardLab/null_terminator
Null terminator
2 parents d1a1b93 + 0560310 commit 2204a60

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

redisql_lib/src/redis.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ pub unsafe fn string_ptr_len(
446446
rm::ffi::RedisModule_StringPtrLen.unwrap()(str, &mut len)
447447
as *mut u8;
448448
let slice = slice::from_raw_parts(base, len);
449-
str::from_utf8_unchecked(slice)
449+
str::from_utf8_unchecked(slice).trim_end_matches(char::from(0))
450450
}
451451

452452
#[repr(C)]

test/correctness/test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,12 @@ def test_without_file(self):
854854
shutil.rmtree(path)
855855
self.assertTrue(True)
856856

857+
class TestNullTerminatedStrings(TestRediSQLWithExec):
858+
def test_null_terminated(self):
859+
with DB(self, "NULL"):
860+
one = self.exec_naked("REDISQL.EXEC", "NULL", "SELECT 1" + b'\x00')
861+
self.assertEquals(one, [[1]])
862+
857863
if __name__ == '__main__':
858864
unittest.main()
859865

0 commit comments

Comments
 (0)