diff --git a/parser.c b/parser.c
index 51264e6f..f15e066b 100644
--- a/parser.c
+++ b/parser.c
@@ -13989,6 +13989,7 @@ xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
     if (pctx != NULL) {
         ctxt->options = pctx->options;
         ctxt->_private = pctx->_private;
+        ctxt->input_id = pctx->input_id + 1;
     }
 
     uri = xmlBuildURI(URL, base);
