Unix API Clang static analysis bug fixes

allocations of 0 size and possible null pointer dereferencing
Change-Id: Ic251f4703b326d4ea9c9f47f313ebaf419a7bd64