Browse Source

Merge pull request #13904 from timothyklemm/hpcc-24202-htpasswd_memory_leak

HPCC-24202 Fix htpasswd memory leak in error handling

Reviewed-By: Russ Whitehead <william.whitehead@lexisnexis.com>
Reviewed-By: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 5 years ago
parent
commit
b5368f9a45
1 changed files with 7 additions and 2 deletions
  1. 7 2
      system/security/plugins/htpasswdSecurity/htpasswdSecurity.cpp

+ 7 - 2
system/security/plugins/htpasswdSecurity/htpasswdSecurity.cpp

@@ -309,9 +309,14 @@ private:
 			io->close();
 			pwFileLastMod = whenChanged;//remember when last changed
 		}
-		catch(IException*)
+        catch(IException* e)
 		{
-			throw MakeStringException(-1, "htpasswd Exception accessing Password file");
+            StringBuffer msg;
+            if (strncmp(e->errorMessage(msg).str(), "htpasswd", 8) == 0)
+                throw;
+            int code = e->errorCode();
+            e->Release();
+            throw MakeStringException(code, "htpasswd Exception accessing Password file: %s", msg.str());
 		}
 		return true;
 	}