diff --git a/lib/codemirror.js b/lib/codemirror.js
index <HASH>..<HASH> 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -1276,7 +1276,7 @@ var CodeMirror = (function() {
       var tc = textChanged; // textChanged can be reset by cursoractivity callback
       if (selectionChanged && options.onCursorActivity)
         options.onCursorActivity(instance);
-      if (tc && options.onChange)
+      if (tc && options.onChange && instance)
         options.onChange(instance, tc);
     }
     var nestedOperation = 0;
don't fire onChange during editor initialization