diff --git a/servers/slapd/back-sql/util.c b/servers/slapd/back-sql/util.c
index 3564527b6e6654b4c364f3caf962af4f25b7fd19..ce2b071abe8a8adbe15bfb329f73760435e2f1df 100644
--- a/servers/slapd/back-sql/util.c
+++ b/servers/slapd/back-sql/util.c
@@ -105,6 +105,7 @@ backsql_strcat_x( struct berbuf *dest, void *memctx, ... )
 				Debug( LDAP_DEBUG_ANY, "backsql_strcat(): "
 					"could not reallocate string buffer.\n",
 					0, 0, 0 );
+				va_end( strs );
 				return NULL;
 			}
 			dest->bb_val.bv_val = tmp_dest;
@@ -212,6 +213,7 @@ backsql_strfcat_x( struct berbuf *dest, void *memctx, const char *fmt, ... )
 				Debug( LDAP_DEBUG_ANY, "backsql_strfcat(): "
 					"could not reallocate string buffer.\n",
 					0, 0, 0 );
+				va_end( strs );
 				return NULL;
 			}
 			dest->bb_val.bv_val = tmp_dest;