From 646d0aa1cf29433254b8189454f4620a30564365 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 8 Jun 2013 17:22:49 +0800 Subject: [PATCH] [LINUX] Fix a compilation error in spine/extension.cpp. --- extensions/spine/extension.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extensions/spine/extension.cpp b/extensions/spine/extension.cpp index 2f973c73f8..dfdda7a96e 100644 --- a/extensions/spine/extension.cpp +++ b/extensions/spine/extension.cpp @@ -53,6 +53,7 @@ void _setFree (void (*free) (void* ptr)) { char* _readFile (const char* path, int* length) { char *data; FILE *file = fopen(path, "rb"); + int readBytes = 0; if (!file) return 0; fseek(file, 0, SEEK_END); @@ -60,10 +61,14 @@ char* _readFile (const char* path, int* length) { fseek(file, 0, SEEK_SET); data = MALLOC(char, *length); - fread(data, 1, *length, file); + readBytes = fread(data, 1, *length, file); fclose(file); - + if (readBytes != *length) + { + FREE(data); + data = NULL; + } return data; } -}} // namespace cocos2d { namespace extension { \ No newline at end of file +}} // namespace cocos2d { namespace extension {