1
0
mirror of https://github.com/GOSTSec/sgminer synced 2025-01-30 08:24:26 +00:00

Added null-termination for kernel build log.

This commit is contained in:
troky 2014-06-05 23:07:55 +02:00
parent f0e47ec8ec
commit 2588394e32

6
ocl.c
View File

@ -619,8 +619,9 @@ build:
size_t log_size; size_t log_size;
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
char *sz_log = (char *)malloc(log_size); char *sz_log = (char *)malloc(log_size + 1);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL); status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL);
sz_log[log_size] = '\0';
applog(LOG_ERR, "%s", sz_log); applog(LOG_ERR, "%s", sz_log);
free(sz_log); free(sz_log);
goto not_built; goto not_built;
@ -756,8 +757,9 @@ built:
size_t log_size; size_t log_size;
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size);
char *sz_log = (char *)malloc(log_size); char *sz_log = (char *)malloc(log_size + 1);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL); status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL);
sz_log[log_size] = '\0';
applog(LOG_ERR, "%s", sz_log); applog(LOG_ERR, "%s", sz_log);
free(sz_log); free(sz_log);
return NULL; return NULL;