From 110d9cfab5a6ae8370d700a90351336161207239 Mon Sep 17 00:00:00 2001 From: Leonid Fedorov Date: Mon, 4 Jul 2022 19:52:30 +0300 Subject: [PATCH] Review fixes --- dbcon/mysql/columnstore_dataload.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/dbcon/mysql/columnstore_dataload.cpp b/dbcon/mysql/columnstore_dataload.cpp index 832170a6d..225576bfb 100644 --- a/dbcon/mysql/columnstore_dataload.cpp +++ b/dbcon/mysql/columnstore_dataload.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2021 MariaDB Corporation +/* Copyright (C) 2022 MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -70,13 +70,16 @@ extern "C" { struct InitData { - CURL* curl; - char* result; + CURL* curl = nullptr; + char* result = nullptr; }; void columnstore_dataload_deinit(UDF_INIT* initid) { InitData* initData = (InitData*)(initid->ptr); + if (!initData) + return; + curl_easy_cleanup(initData->curl); delete initData->result; } @@ -174,17 +177,17 @@ extern "C" my_bool columnstore_dataload_init(UDF_INIT* initid, UDF_ARGS* args, char* message) { - initid->max_length = 1000 * 1000; - InitData* initData = new InitData; - initData->curl = curl_easy_init(); - initid->ptr = (char*)(initData); - if (args->arg_count != 3 && args->arg_count != 4) { strcpy(message, "COLUMNSTORE_DATALOAD() takes three or four arguments: (table, filename, bucket) or (table, filename, bucket, database)"); return 1; } + initid->max_length = 1000 * 1000; + InitData* initData = new InitData; + initData->curl = curl_easy_init(); + initid->ptr = (char*)(initData); + return 0; } } \ No newline at end of file