< prev index next >

src/java.desktop/windows/native/libawt/windows/WPrinterJob.cpp

Print this page

        

@@ -268,18 +268,23 @@
                 if (info4->Attributes & PRINTER_ATTRIBUTE_NETWORK) {
                     pNetworkPrinterLoc[remotePrintersCount++] = i;
                 }
             }
 
+            // return remote printers only if the list contains it.
+            if (remotePrintersCount > 0) {
             // Allocate space only for the network type printers
             nameArray = env->NewObjectArray(remotePrintersCount, clazz, NULL);
             if (nameArray == NULL) {
                 throw std::bad_alloc();
             }
         } else {
             nameArray = NULL;
         }
+        } else {
+            nameArray = NULL;
+        }
 
         // Loop thro' network printers list only
         for (int i = 0; i < remotePrintersCount; i++) {
             PRINTER_INFO_4 *info4 = (PRINTER_INFO_4 *)
                 (pPrinterEnum + pNetworkPrinterLoc[i] * sizeof(PRINTER_INFO_4));
< prev index next >