Fix the incorrect script status assumption.
diff --git a/lib/bcc/Script.cpp b/lib/bcc/Script.cpp
index 7a1706a..a53377a 100644
--- a/lib/bcc/Script.cpp
+++ b/lib/bcc/Script.cpp
@@ -38,20 +38,22 @@
                    long bitcodeFileCRC32,
                    const BCCchar *resName,
                    const BCCchar *cacheDir) {
-  if (mStatus != ScriptStatus::Unknown) {
+  if (mStatus == ScriptStatus::Unknown) {
+    mCompiled = new (nothrow) ScriptCompiled(this);
+
+    if (!mCompiled) {
+      mErrorCode = BCC_OUT_OF_MEMORY;
+      return 1;
+    }
+
+    mStatus = ScriptStatus::Compiled;
+  }
+
+  if (mStatus != ScriptStatus::Compiled) {
     mErrorCode = BCC_INVALID_OPERATION;
     return 1;
   }
 
-  mCompiled = new (nothrow) ScriptCompiled(this);
-
-  if (!mCompiled) {
-    mErrorCode = BCC_OUT_OF_MEMORY;
-    return 1;
-  }
-
-  mStatus = ScriptStatus::Compiled;
-
   if (mpExtSymbolLookupFn) {
     mCompiled->registerSymbolCallback(mpExtSymbolLookupFn,
                                       mpExtSymbolLookupFnContext);