diff options
author | Sergei Golubchik <sergii@pisem.net> | 2013-04-19 20:35:32 +0200 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2013-04-19 20:35:32 +0200 |
commit | faf4d99d223d8438eb1599377aa1db3b2ab5bf24 (patch) | |
tree | fee4bd39330af62bd4e908c93214ab774e1b8b54 /sql/sql_string.cc | |
parent | 4b169cd7c1ba846d8e4b613a788007609178cdad (diff) | |
download | mariadb-git-faf4d99d223d8438eb1599377aa1db3b2ab5bf24.tar.gz |
String::append_for_single_quote() should signal OOM condition,
just like other String::append() methods do
Diffstat (limited to 'sql/sql_string.cc')
-rw-r--r-- | sql/sql_string.cc | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 095c557c531..21748861204 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -1079,7 +1079,8 @@ outp: characters as necessary. Does not add the enclosing quotes, this is left up to caller. */ -void String::append_for_single_quote(const char *st, uint len) +#define APPEND(X) if (append(X)) return 1; else break +bool String::append_for_single_quote(const char *st, uint len) { const char *end= st+len; for (; st < end; st++) @@ -1087,28 +1088,16 @@ void String::append_for_single_quote(const char *st, uint len) uchar c= *st; switch (c) { - case '\\': - append(STRING_WITH_LEN("\\\\")); - break; - case '\0': - append(STRING_WITH_LEN("\\0")); - break; - case '\'': - append(STRING_WITH_LEN("\\'")); - break; - case '\n': - append(STRING_WITH_LEN("\\n")); - break; - case '\r': - append(STRING_WITH_LEN("\\r")); - break; - case '\032': // Ctrl-Z - append(STRING_WITH_LEN("\\Z")); - break; - default: - append(c); + case '\\': APPEND(STRING_WITH_LEN("\\\\")); + case '\0': APPEND(STRING_WITH_LEN("\\0")); + case '\'': APPEND(STRING_WITH_LEN("\\'")); + case '\n': APPEND(STRING_WITH_LEN("\\n")); + case '\r': APPEND(STRING_WITH_LEN("\\r")); + case '\032': APPEND(STRING_WITH_LEN("\\Z")); + default: APPEND(c); } } + return 0; } void String::print(String *str) |