Added patch for SECURITY-29 and fixed for C++ code