diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG
index 64b69d8113fc6b61ee7b5a67028c5b2a5ed7bc0d..b217deac9bd083c7f17fd2f2cd52e1d7d45c8665 100644
--- a/smartmontools/CHANGELOG
+++ b/smartmontools/CHANGELOG
@@ -43,6 +43,8 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [DL] FreeBSD: check reallocf() result for failures
+
   [AS] FreeBSD: fixing crash on kFreeBSD (#29), patch provided by Petr Salinger
 
   [CF] Makefile.am: 'make check' now tests the syntax of drivedb.h.
diff --git a/smartmontools/os_freebsd.cpp b/smartmontools/os_freebsd.cpp
index a439b3d23e5bef0fe6e106f65db0a8bef43e35b2..b06ca5ed9359924e95c4121f2519e4f8515e1083 100644
--- a/smartmontools/os_freebsd.cpp
+++ b/smartmontools/os_freebsd.cpp
@@ -1535,6 +1535,12 @@ int get_dev_names_ata(char*** names) {
     };
   };  
   mp = (char **)reallocf(mp,n*(sizeof (char*))); // shrink to correct size
+  if (mp == NULL && n > 0 ) { // reallocf never fail for size=0, but may return NULL
+    serrno=errno;
+    pout("Out of memory constructing scan device list (on line %d)\n", __LINE__);
+    n = -1;
+    goto end;
+  };
   bytes += (n)*(sizeof(char*)); // and set allocated byte count
 
 end: