diff --git a/capsule/capsule-dlmopen.c b/capsule/capsule-dlmopen.c
index 137b065b527e7f746f28a0ad4b3deaa02911eee4..9483b6cdd0994d20d6282da318c02883effde7d4 100644
--- a/capsule/capsule-dlmopen.c
+++ b/capsule/capsule-dlmopen.c
@@ -328,7 +328,14 @@ void resolve_symlink_prefixed (ldlibs_t *ldlibs, int i)
     while( resolve_link(ldlibs->prefix.path, resolved, link_dir) )
     {
         LDLIB_DEBUG( ldlibs, DEBUG_PATH, "  resolved to: %s", resolved );
-        count++;
+
+        if( ++count > MAXSYMLINKS )
+        {
+            fprintf( stderr, "%s: MAXSYMLINKS (%d) exceeded resolving %s\n",
+                     __PRETTY_FUNCTION__, MAXSYMLINKS,
+                     ldlibs->needed[i].path );
+            break;
+        }
     }
 
     if( count )