From 35162ce669bd02d07c7d1e708c2932dab7248690 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Thu, 8 Mar 2012 17:45:23 -0500 Subject: util: Fix file loading bug --- util.c | 4 ++-- 1 file 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; -- cgit v1.2.3