diff options
| author | Ray <[email protected]> | 2023-02-22 17:28:25 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2023-02-22 17:28:25 +0100 |
| commit | d652b95fbfc06b7a996386c9d212e9fe2d669ed8 (patch) | |
| tree | df486098a25a2594a7be668fc76d9017ae75c09f /src | |
| parent | 153470d60503e840d5b0a15abe3647a4316e988c (diff) | |
| download | raylib-d652b95fbfc06b7a996386c9d212e9fe2d669ed8.tar.gz raylib-d652b95fbfc06b7a996386c9d212e9fe2d669ed8.zip | |
ADDED: Security checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/rtext.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/rtext.c b/src/rtext.c index 3e838f85..7cce1eb8 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1568,17 +1568,20 @@ const char *TextToUpper(const char *text) static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); - for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) + if (text != NULL) { - if (text[i] != '\0') + for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) { - buffer[i] = (char)toupper(text[i]); - //if ((text[i] >= 'a') && (text[i] <= 'z')) buffer[i] = text[i] - 32; + if (text[i] != '\0') + { + buffer[i] = (char)toupper(text[i]); + //if ((text[i] >= 'a') && (text[i] <= 'z')) buffer[i] = text[i] - 32; - // TODO: Support UTF-8 diacritics to upper-case - //if ((text[i] >= 'à') && (text[i] <= 'ý')) buffer[i] = text[i] - 32; + // TODO: Support UTF-8 diacritics to upper-case + //if ((text[i] >= 'à') && (text[i] <= 'ý')) buffer[i] = text[i] - 32; + } + else { buffer[i] = '\0'; break; } } - else { buffer[i] = '\0'; break; } } return buffer; @@ -1591,14 +1594,17 @@ const char *TextToLower(const char *text) static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); - for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) + if (text != NULL) { - if (text[i] != '\0') + for (int i = 0; i < MAX_TEXT_BUFFER_LENGTH; i++) { - buffer[i] = (char)tolower(text[i]); - //if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32; + if (text[i] != '\0') + { + buffer[i] = (char)tolower(text[i]); + //if ((text[i] >= 'A') && (text[i] <= 'Z')) buffer[i] = text[i] + 32; + } + else { buffer[i] = '\0'; break; } } - else { buffer[i] = '\0'; break; } } return buffer; @@ -1611,20 +1617,23 @@ const char *TextToPascal(const char *text) static char buffer[MAX_TEXT_BUFFER_LENGTH] = { 0 }; memset(buffer, 0, MAX_TEXT_BUFFER_LENGTH); - buffer[0] = (char)toupper(text[0]); - - for (int i = 1, j = 1; i < MAX_TEXT_BUFFER_LENGTH; i++, j++) + if (text != NULL) { - if (text[j] != '\0') + buffer[0] = (char)toupper(text[0]); + + for (int i = 1, j = 1; i < MAX_TEXT_BUFFER_LENGTH; i++, j++) { - if (text[j] != '_') buffer[i] = text[j]; - else + if (text[j] != '\0') { - j++; - buffer[i] = (char)toupper(text[j]); + if (text[j] != '_') buffer[i] = text[j]; + else + { + j++; + buffer[i] = (char)toupper(text[j]); + } } + else { buffer[i] = '\0'; break; } } - else { buffer[i] = '\0'; break; } } return buffer; |
