Allow libnetapi_net_init() to be called more than once without
leaking libnetapi_ctx allocated on a previous call, which is
currently the case in the `net rpc` code.
Signed-off-by: Pavel Kalugin <pkalugin@inno.tech>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
{
NET_API_STATUS status;
struct libnetapi_ctx *ctx = NULL;
- TALLOC_CTX *frame = talloc_stackframe();
+ TALLOC_CTX *frame = NULL;
+
+ if (stat_ctx != NULL && libnetapi_initialized) {
+ *context = stat_ctx;
+ return NET_API_STATUS_SUCCESS;
+ }
+ frame = talloc_stackframe();
ctx = talloc_zero(frame, struct libnetapi_ctx);
if (!ctx) {
TALLOC_FREE(frame);