diff --git a/core/meta/src/TIsAProxy.cxx b/core/meta/src/TIsAProxy.cxx
index eb9d4ac9b51881d5fc783ecee6631246208c8cae..b7a82c5d3fb0a584a06580cd4291babcc170d29c 100644
--- a/core/meta/src/TIsAProxy.cxx
+++ b/core/meta/src/TIsAProxy.cxx
@@ -118,10 +118,13 @@ TClass* TIsAProxy::operator()(const void *obj)
 
    // Check if type is already in sub-class cache
    auto last = ToPair(FindSubType(typ));
-   if ( last == nullptr || last->second == nullptr )  {
+   if ( last == nullptr )  {
       // Last resort: lookup root class
       auto cls = TClass::GetClass(*typ);
-      last = ToPair(CacheSubType(typ,cls));
+      if (cls)
+         last = ToPair(CacheSubType(typ,cls));
+      else
+         return nullptr; // Don't record failed searches (a library might be loaded between now and the next search).
    }
 
    UChar_t next = fNextLastSlot++;
@@ -132,7 +135,7 @@ TClass* TIsAProxy::operator()(const void *obj)
    }
    fLasts[next].store(last);
 
-   return last == nullptr ? nullptr: last->second;
+   return last == nullptr ? nullptr : last->second;
 }
 
 ////////////////////////////////////////////////////////////////////////////////