From 12d82f2f071e794749d9c9def9dcf5d484645e4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Z=C5=AFna?= Date: Thu, 18 Jul 2013 14:45:58 +0200 Subject: [PATCH] fix for issue 169, on some windows 7 On some windows machine alerts are shown, when something goes bad when trying to list com ports. dhToggleExceptions(FALSE) turns those off. But then, there is sometimes huge number of serial ports reported, which do not have their name set. We check for the name existence and proceed only when it is available. For us it fixes https://github.com/voodootikigod/node-serialport/issues/169 reliably on multiple machines. --- src/serialport_win.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index 7feb506..466a237 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -354,7 +354,7 @@ void EIO_List(uv_work_t* req) { DISPATCH_OBJ(colDevices); dhInitialize(TRUE); - dhToggleExceptions(TRUE); + dhToggleExceptions(FALSE); dhGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\cimv2", NULL, &wmiSvc); dhGetValue(L"%o", &colDevices, wmiSvc, L".ExecQuery(%S)", L"Select * from Win32_PnPEntity"); @@ -369,7 +369,7 @@ void EIO_List(uv_work_t* req) { dhGetValue(L"%s", &name, objDevice, L".Name"); dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID"); - if( (match = strstr( name, "(COM" )) != NULL ) { // look for "(COM23)" + if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)" // 'Manufacturuer' can be null, so only get it if we need it dhGetValue(L"%s", &manu, objDevice, L".Manufacturer"); port_count++;