Blob Blame History Raw
From 0d2e40bb182d8e417a5dac9000e5a5bb17422adf Mon Sep 17 00:00:00 2001
From: Dennis Schridde <devurandom@gmx.net>
Date: Thu, 31 May 2012 17:30:49 +0200
Subject: [PATCH] Fix potential Lua error (attempt to concatenate a nil value)
 when ldap_parse_result returns a NULL error message

---
 src/lualdap.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lualdap.c b/src/lualdap.c
index 99c756e..d170038 100644
--- a/src/lualdap.c
+++ b/src/lualdap.c
@@ -436,10 +436,14 @@ static int result_message (lua_State *L) {
 			default:
 				lua_pushnil (L);
 				lua_pushliteral (L, LUALDAP_PREFIX);
-				lua_pushstring (L, msg);
-				lua_pushliteral (L, " ");
 				lua_pushstring (L, ldap_err2string(err));
-				lua_concat (L, 4);
+				lua_concat (L, 2);
+				if (msg != NULL) {
+					lua_pushliteral (L, " (");
+					lua_pushstring (L, msg);
+					lua_pushliteral (L, ")");
+					lua_concat (L, 4);
+				}
 				ret = 2;
 		}
 		ldap_memfree (mdn);
-- 
1.9.3