coverity#1255907 Explicit null dereferenced

Change-Id: I5b7be6698e2028f9b882c2f7deb96739bc968098
(cherry picked from commit 83ea7e76da284be6380fcdadf9848276fcdd080a)
coverity#1255905 Buffer not null terminated

Change-Id: I0822f04a296ec6c8c6ae559aef320a59afc8aa0d
(cherry picked from commit 24ee4cba937d1b69cb6b5fdb9d1b8116546e5a6e)