lib-pyldb: Avoid crash when copying MessageElements between Python Message objects
commit2d67335f681a60a636e48107d908778806a0b15f
authorKamen Mazdrashki <kamenim@samba.org>
Wed, 12 Nov 2014 00:17:56 +0000 (12 01:17 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 25 Nov 2014 04:04:08 +0000 (25 05:04 +0100)
tree651bbaf3e8e8b31ade9dd5bbd69fb7abaa9eec65
parent7f121d3860ee3289f5fd397ab3312634d11cb2f2
lib-pyldb: Avoid crash when copying MessageElements between Python Message objects

This patch allows for following snipets in Python:
  res = ldb.search(...)
  m_from = res[0]
  m_to = Message()
  m_to.add(m_from["attrName"])

The problem previously is that we are trying to reference a
ldb_message_element that may not be a memory context on its own.
For instance, when search request from above example returns
Messages with more than one attribute, this leads immediately
to "Bad talloc magic value" crash, every message element beside
the first one is not a memory context

Signed-off-by: Kamen Mazdrashki <kamenim@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb/pyldb.c