[bugs:#2663] sfcc cannot reconnect with sfcb if sfcb restarts
diff --git a/backend/cimxml/client.c b/backend/cimxml/client.c
index e076544..9fa93b3 100644
--- a/backend/cimxml/client.c
+++ b/backend/cimxml/client.c
@@ -304,6 +304,8 @@
   if (con->mStatus.msg) CMRelease(con->mStatus.msg);
 
   free(con);
+  con = NULL;
+
   return rc;
 }
 /* --------------------------------------------------------------------------*/
@@ -990,8 +992,9 @@
   }
  
   if (cl->connection) CMRelease(cl->connection);
-
   free(cl);
+  cl = NULL;
+
   return rc;
 }
 
@@ -2893,8 +2896,6 @@
     curl_global_cleanup();
   }
 
-  free(env);
-
   return NULL;
 }
 
diff --git a/cimc/cimcclient.c b/cimc/cimcclient.c
index 320afbd..a2fb6d3 100644
--- a/cimc/cimcclient.c
+++ b/cimc/cimcclient.c
@@ -99,9 +99,15 @@
    void *lib=NULL;
    if (env) {
      lib = env->hdl;
-     env->ft->release(env);
+     void* check = env->ft->release(env);
      if (lib) {
        dlclose(lib);
      }
+
+     /* if check is for compatability:
+        SFCB pre-1.4.6 free'd the env during release() and returned lib pointer */
+     if (!check) {
+       free(env);
+     }
    }
 }