mirror of
https://github.com/GOSTSec/sgminer
synced 2025-02-10 14:04:16 +00:00
api.c allow NULL data displayed as (null)
This commit is contained in:
parent
37e95ced6b
commit
06f5f35ad4
10
api.c
10
api.c
@ -179,6 +179,7 @@ static const char *DYNAMIC = _DYNAMIC;
|
|||||||
|
|
||||||
static const char *YES = "Y";
|
static const char *YES = "Y";
|
||||||
static const char *NO = "N";
|
static const char *NO = "N";
|
||||||
|
static const char *NULLSTR = "(null)";
|
||||||
|
|
||||||
static const char *DEVICECODE = ""
|
static const char *DEVICECODE = ""
|
||||||
#ifdef HAVE_OPENCL
|
#ifdef HAVE_OPENCL
|
||||||
@ -683,6 +684,13 @@ static struct api_data *api_add_data_full(struct api_data *root, char *name, enu
|
|||||||
|
|
||||||
api_data->data_was_malloc = copy_data;
|
api_data->data_was_malloc = copy_data;
|
||||||
|
|
||||||
|
// Avoid crashing on bad data
|
||||||
|
if (data == NULL) {
|
||||||
|
api_data->type = type = API_CONST;
|
||||||
|
data = (void *)NULLSTR;
|
||||||
|
api_data->data_was_malloc = copy_data = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (!copy_data)
|
if (!copy_data)
|
||||||
api_data->data = data;
|
api_data->data = data;
|
||||||
else
|
else
|
||||||
@ -1763,7 +1771,7 @@ static void summary(__maybe_unused SOCKETTYPE c, __maybe_unused char *param, boo
|
|||||||
#ifdef WANT_CPUMINE
|
#ifdef WANT_CPUMINE
|
||||||
char *algo = (char *)(algo_names[opt_algo]);
|
char *algo = (char *)(algo_names[opt_algo]);
|
||||||
if (algo == NULL)
|
if (algo == NULL)
|
||||||
algo = "(null)";
|
algo = (char *)NULLSTR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
|
utility = total_accepted / ( total_secs ? total_secs : 1 ) * 60;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user