summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util.c b/util.c
index 33031cb..3a95c99 100644
--- a/util.c
+++ b/util.c
@@ -127,13 +127,13 @@ unsigned cluCreateKernel(cl_context context, cl_device_id device_id,
/* Read code */
do {
- code = realloc(code, (bytes_read + CODE_CHUNK) * sizeof(unsigned char));
+ code = realloc(code, (code_len + CODE_CHUNK) * sizeof(unsigned char));
if (!code) {
fprintf(stderr, "Failed to realloc code.\n");
return 0;
}
- bytes_read = read(fd, code + bytes_read, CODE_CHUNK);
+ bytes_read = read(fd, code + code_len, CODE_CHUNK);
if (bytes_read < 0) {
fprintf(stderr, "Failed to read code.\n");
return 0;