summaryrefslogtreecommitdiff
path: root/mysys/charset.c
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-02 22:08:51 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-02 22:08:51 +0200
commit9809f05199aeb0b67991fac41bd86f38730768dc (patch)
treefa2792ff86d0da014b535d743759810612338042 /mysys/charset.c
parent0accbd0364e0333e0b119aa9ce93e34ded9df6cb (diff)
parent5a0e7394a5ae0c7b6a1ea35b7ea3a8985325987a (diff)
downloadmariadb-git-9809f05199aeb0b67991fac41bd86f38730768dc.tar.gz
5.5-merge
Diffstat (limited to 'mysys/charset.c')
-rw-r--r--mysys/charset.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/mysys/charset.c b/mysys/charset.c
index 7f414fbad97..f859ceae394 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -415,6 +415,7 @@ CHARSET_INFO *default_charset_info = &my_charset_latin1;
void add_compiled_collation(struct charset_info_st *cs)
{
+ DBUG_ASSERT(cs->number < array_elements(all_charsets));
all_charsets[cs->number]= cs;
cs->state|= MY_CS_AVAILABLE;
}
@@ -526,14 +527,17 @@ uint get_charset_number(const char *charset_name, uint cs_flags)
const char *get_charset_name(uint charset_number)
{
- CHARSET_INFO *cs;
my_pthread_once(&charsets_initialized, init_available_charsets);
- cs=all_charsets[charset_number];
- if (cs && (cs->number == charset_number) && cs->name )
- return (char*) cs->name;
+ if (charset_number < array_elements(all_charsets))
+ {
+ CHARSET_INFO *cs= all_charsets[charset_number];
+
+ if (cs && (cs->number == charset_number) && cs->name)
+ return (char*) cs->name;
+ }
- return (char*) "?"; /* this mimics find_type() */
+ return "?"; /* this mimics find_type() */
}
@@ -542,6 +546,8 @@ static CHARSET_INFO *get_internal_charset(uint cs_number, myf flags)
char buf[FN_REFLEN];
struct charset_info_st *cs;
+ DBUG_ASSERT(cs_number < array_elements(all_charsets));
+
if ((cs= (struct charset_info_st*) all_charsets[cs_number]))
{
if (cs->state & MY_CS_READY) /* if CS is already initialized */
@@ -586,8 +592,8 @@ CHARSET_INFO *get_charset(uint cs_number, myf flags)
return default_charset_info;
my_pthread_once(&charsets_initialized, init_available_charsets);
-
- if (!cs_number || cs_number > array_elements(all_charsets))
+
+ if (cs_number >= array_elements(all_charsets))
return NULL;
cs=get_internal_charset(cs_number, flags);