소스 검색

SOCL: make sure we do not try to dynamically allocate 0 bytes.

[scan-build] Undefined allocation of 0 bytes x2
Cyril Roelandt 13 년 전
부모
커밋
0408173814
2개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 0
      socl/src/cl_createprogramwithsource.c
  2. 4 1
      socl/src/command_queue.c

+ 1 - 0
socl/src/cl_createprogramwithsource.c

@@ -80,6 +80,7 @@ soclCreateProgramWithSource(cl_context      context,
       *errcode_ret = CL_SUCCESS;
 
    device_count = starpu_opencl_worker_get_count();
+   assert(device_count > 0);
    DEBUG_MSG("Worker count: %d\n", device_count);
 
    /* Check arguments */

+ 4 - 1
socl/src/command_queue.c

@@ -58,8 +58,11 @@ void command_queue_dependencies_implicit(
 	 * Return dependencies
 	 *********************/
 
-	cl_event * evs = malloc(ndeps * sizeof(cl_event));
 	int n = 0;
+	cl_event * evs = NULL;
+	if (ndeps > 0)
+		evs = malloc(ndeps * sizeof(cl_event));
+
 
 	/* Add dependency to last barrier if applicable */
 	if (cq->barrier != NULL)