Branch: master

3fdd5c96 2015-10-23 03:01:56 Timothy Pearson
Fix memory leak on bind failure
Fix minor issues with comments
M src/libtdeldap.cpp
diff --git a/src/libtdeldap.cpp b/src/libtdeldap.cpp
index 8a14cc3..8bb3c2a 100644
--- a/src/libtdeldap.cpp
+++ b/src/libtdeldap.cpp
@@ -407,10 +407,14 @@
 							}
 						}
 					}
-					// clean up
+					// Clean up
 					ldap_msgfree(msg);
 
 					// All done!
+					ldap_unbind_ext_s(ldapconn, NULL, NULL);
+				}
+				else {
+					// Clean up
 					ldap_unbind_ext_s(ldapconn, NULL, NULL);
 				}
 			}
@@ -765,7 +769,7 @@
 				users.append(parseLDAPUserRecord(entry));
 			}
 
-			// clean up
+			// Clean up
 			ldap_msgfree(msg);
 
 			if (mretcode) *mretcode = 0;
@@ -843,7 +847,7 @@
 					users.append(parseLDAPUserRecord(entry));
 				}
 
-				// clean up
+				// Clean up
 				ldap_msgfree(msg);
 			} while (morePages);
 
@@ -876,7 +880,7 @@
 			userinfo = parseLDAPUserRecord(entry);
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return userinfo;
@@ -907,7 +911,7 @@
 			groupinfo = parseLDAPGroupRecord(entry);
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return groupinfo;
@@ -2513,7 +2517,7 @@
 				groups.append(parseLDAPGroupRecord(entry));
 			}
 
-			// clean up
+			// Clean up
 			ldap_msgfree(msg);
 
 			if (mretcode) *mretcode = 0;
@@ -2591,7 +2595,7 @@
 					groups.append(parseLDAPGroupRecord(entry));
 				}
 
-				// clean up
+				// Clean up
 				ldap_msgfree(msg);
 			} while (morePages);
 
@@ -2634,7 +2638,7 @@
 				machines.append(parseLDAPMachineRecord(entry));
 			}
 
-			// clean up
+			// Clean up
 			ldap_msgfree(msg);
 
 			if (mretcode) *mretcode = 0;
@@ -2712,7 +2716,7 @@
 					machines.append(parseLDAPMachineRecord(entry));
 				}
 
-				// clean up
+				// Clean up
 				ldap_msgfree(msg);
 			} while (morePages);
 
@@ -2794,7 +2798,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		if (mretcode) *mretcode = 0;
@@ -3088,7 +3092,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return realmCAMaster;
@@ -3191,7 +3195,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return returncode;
@@ -3272,7 +3276,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return 0;
@@ -3557,7 +3561,7 @@
 			builtininfo = parseLDAPTDEBuiltinsRecord(entry);
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return builtininfo;
@@ -3593,7 +3597,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		// Set OpenLDAP defaults
@@ -3612,7 +3616,7 @@
 			replicationinfo = parseLDAPMasterReplicationRecord(replicationinfo, entry);
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return replicationinfo;
@@ -3938,7 +3942,7 @@
 					}
 				}
 
-				// clean up
+				// Clean up
 				ldap_msgfree(msg);
 
 				if (!haveOlcOverlaySyncProv) {
@@ -3988,7 +3992,7 @@
 					}
 				}
 
-				// clean up
+				// Clean up
 				ldap_msgfree(msg);
 
 				if (!haveOlcOverlaySyncProv) {
@@ -4097,7 +4101,7 @@
 			}
 		}
 
-		// clean up
+		// Clean up
 		ldap_msgfree(msg);
 
 		return returncode;