summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2020-02-28 00:32:46 +0100
committerRay <[email protected]>2020-02-28 00:32:46 +0100
commitf2247c6f0a2c200937f40c09d829e48360d42df7 (patch)
treea0222537ea78dfcd0073b2f40bf552efda4b9993
parent05992a6fce2f9233ab4dec842301290c328319a8 (diff)
downloadraylib-f2247c6f0a2c200937f40c09d829e48360d42df7.tar.gz
raylib-f2247c6f0a2c200937f40c09d829e48360d42df7.zip
REVIEWED: LoadText()
-rw-r--r--src/rlgl.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/rlgl.h b/src/rlgl.h
index b63ab61b..0bbbf2fd 100644
--- a/src/rlgl.h
+++ b/src/rlgl.h
@@ -3007,7 +3007,14 @@ char *LoadText(const char *fileName)
{
text = (char *)RL_MALLOC(sizeof(char)*(size + 1));
int count = fread(text, sizeof(char), size, textFile);
- if (size == count) text[count] = '\0';
+
+ // WARNING: \r\n is converted to \n on reading, so,
+ // read bytes count gets reduced by the number of lines
+ if (count < size)
+ {
+ text = RL_REALLOC(text, count + 1);
+ text[count] = '\0';
+ }
}
fclose(textFile);