liblog: fix an undefined-behavor in __write_to_log_daemon()

The behavior of passing NULL to c-string functions is undefined.

Test: passed clang-tidy checks
Bug: none

Change-Id: Ie7bcc43cd19bc4a1c314381af3929eae0a6154b9
This commit is contained in:
Ting-Yuan Huang 2017-02-07 16:40:35 -08:00
parent 8eb237ad57
commit 6efb877973

View file

@ -343,7 +343,7 @@ static int __write_to_log_daemon(log_id_t log_id, struct iovec *vec, size_t nr)
}
}
/* tag must be nul terminated */
if (strnlen(tag, len) >= len) {
if (tag && strnlen(tag, len) >= len) {
tag = NULL;
}