Browse Source

Make sure log string is null-terminated.

djm34
troky 11 years ago
parent
commit
24fa44e12b
  1. 2
      logging.c
  2. 3
      ocl/build_kernel.c

2
logging.c

@ -70,7 +70,7 @@ void vapplogsiz(int prio, int size, const char* fmt, va_list args)
{ {
if (opt_debug || prio != LOG_DEBUG) { if (opt_debug || prio != LOG_DEBUG) {
if (use_syslog || opt_log_output || prio <= opt_log_level) { if (use_syslog || opt_log_output || prio <= opt_log_level) {
char *tmp42 = (char *)calloc(size, 1); char *tmp42 = (char *)calloc(size + 1, 1);
vsnprintf(tmp42, size, fmt, args); vsnprintf(tmp42, size, fmt, args);
_applog(prio, tmp42, false); _applog(prio, tmp42, false);
free(tmp42); free(tmp42);

3
ocl/build_kernel.c

@ -126,8 +126,9 @@ cl_program build_opencl_kernel(build_kernel_data *data, const char *filename)
applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status); applog(LOG_ERR, "Error %d: Building Program (clBuildProgram)", status);
status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &log_size); status = clGetProgramBuildInfo(program, *data->device, 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(program, *data->device, CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL); status = clGetProgramBuildInfo(program, *data->device, CL_PROGRAM_BUILD_LOG, log_size, sz_log, NULL);
sz_log[log_size] = '\0';
applogsiz(LOG_ERR, log_size, "%s", sz_log); applogsiz(LOG_ERR, log_size, "%s", sz_log);
free(sz_log); free(sz_log);
goto out; goto out;

Loading…
Cancel
Save