nativewindow: report errors on error to allocate a handle

At the moment, `outBuffer` won't be set if `err == 0 && gbuffer->handle
!= nullptr`, even though we return a zero value for `err`. This causes
us to pass nullptr to AHardwareBuffer_release in
AHardwareBuffer_isSupported, which isn't correct.

Caught by the static analyzer:

> frameworks/native/libs/nativewindow/AHardwareBuffer.cpp:394:9:
warning: Null passed to a callee that requires a non-null 1st parameter
[clang-analyzer-nullability.NullPassedToNonnull]

This also replaces 0 with nullptr, since we're checking a pointer's
value here.

Bug: None
Test: TreeHugger
Change-Id: Id2fad234f98eda71b06419193e15cbfb5fa39bf1
diff --git a/libs/nativewindow/AHardwareBuffer.cpp b/libs/nativewindow/AHardwareBuffer.cpp
index 1ec73ce..3030068 100644
--- a/libs/nativewindow/AHardwareBuffer.cpp
+++ b/libs/nativewindow/AHardwareBuffer.cpp
@@ -51,13 +51,13 @@
             std::string("AHardwareBuffer pid [") + std::to_string(getpid()) + "]"));
 
     status_t err = gbuffer->initCheck();
-    if (err != 0 || gbuffer->handle == 0) {
+    if (err != 0 || gbuffer->handle == nullptr) {
         if (err == NO_MEMORY) {
             GraphicBuffer::dumpAllocationsToSystemLog();
         }
         ALOGE("GraphicBuffer(w=%u, h=%u, lc=%u) failed (%s), handle=%p",
                 desc->width, desc->height, desc->layers, strerror(-err), gbuffer->handle);
-        return err;
+        return err == 0 ? UNKNOWN_ERROR : err;
     }
 
     *outBuffer = AHardwareBuffer_from_GraphicBuffer(gbuffer.get());