Bugfix: crash when apcupsd isnt running
authorNikolas Garofil <garo@dunaldi.garofil.be>
Mon, 16 Nov 2009 19:19:57 +0000 (20:19 +0100)
committerNikolas Garofil <garo@dunaldi.garofil.be>
Mon, 16 Nov 2009 19:19:57 +0000 (20:19 +0100)
src/apcupsd.c

index d6b6e76..7bec156 100644 (file)
@@ -181,7 +181,7 @@ void update_apcupsd(void) {
                        break;
                }
 #ifdef HAVE_GETHOSTBYNAME_R
-               if (gethostbyname_r(info.apcupsd.host, &he_mem, hostbuff, sizeof(hostbuff), &he, &he_errno)) {
+               if (gethostbyname_r(info.apcupsd.host, &he_mem, hostbuff, sizeof(hostbuff), &he, &he_errno) || !he ) {
                        NORM_ERR("APCUPSD gethostbyname_r: %s", hstrerror(h_errno));
                        break;
                }