deimos_lib.free_memory.argtypes = [ctypes.c_void_p] deimos_lib.free_memory.restype = None app = Flask(__name__) CORS(app, resources={r"/*": {"origins": "*"}}) @app.route("/encrypt", methods=["POST"]) def encrypt(): data = request.json plaintext = data.get("text", # Free memory allocated by C++ deimos_lib.free_memory(ciphertext_ptr) return jsonify({"ciphertext": ciphertext.hex()}) @app.route("/decrypt", methods=["POST"]) @cross_origin() def decrypt(): data = request.json ciphertext = bytes.fromhex(data.get("text", "")) key = data.get("key", "").encode("utf-8") # Convert ciphertext to C array ciphertext_array = (ctypes.c_uint8 * len(ciphertext))(*ciphertext) # Call C++ decryption function plaintext_ptr = deimos_lib.deimosCipherDecrypt(ciphertext_array, len(ciphertext), key) if not plaintext_ptr: return jsonify({"error": "Decryption failed!"}), 400 # Convert C string pointer to Python string plaintext = ctypes.cast(plaintext_ptr, ctypes.c_char_p).value.decode("utf-8") # Free memory allocated by C++ deimos_lib.free_memory(plaintext_ptr) return jsonify({"plaintext": plaintext}) if __name__ == "__main__": app.run(host="0.0.0.0", port=5000) the encryption function works properly but decryption shows munmap_chunk(): invalid pointer... i tried new() and malloc() in my core file but none worked. can anyone help me out Continue reading...