]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
string-util: add missing assertion in cellescape
authorMike Yuan <me@yhndnzj.com>
Wed, 3 Apr 2024 15:00:55 +0000 (23:00 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 3 Apr 2024 15:51:11 +0000 (23:51 +0800)
src/basic/string-util.c

index b50f45f7f4a5407a9ed1c9dfa93db1a17fd542e3..f3ab2dc2223a5c97671a0ad889c43e8a1de5f2e4 100644 (file)
@@ -562,7 +562,9 @@ char *cellescape(char *buf, size_t len, const char *s) {
 
         size_t i = 0, last_char_width[4] = {}, k = 0;
 
+        assert(buf);
         assert(len > 0); /* at least a terminating NUL */
+        assert(s);
 
         for (;;) {
                 char four[4];
@@ -612,7 +614,7 @@ char *cellescape(char *buf, size_t len, const char *s) {
         else
                 assert(i + 1 <= len);
 
- done:
+done:
         buf[i] = '\0';
         return buf;
 }