summaryrefslogtreecommitdiff
path: root/strings
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-06-01 15:51:25 +0200
committerSergei Golubchik <serg@mariadb.org>2015-06-01 15:51:25 +0200
commit5091a4ba755250ed8e35f4f5a39a118d476cd8f1 (patch)
tree370ba468d78204544b56e9d967d8d09e1317a1ed /strings
parent84eaf0911f311acba797c265ef7508ab6c108b35 (diff)
parent0880284bf715b4916cc735e19b76d1062c2bfdcf (diff)
downloadmariadb-git-5091a4ba755250ed8e35f4f5a39a118d476cd8f1.tar.gz
Merge tag 'mariadb-10.0.19' into 10.1
Diffstat (limited to 'strings')
-rw-r--r--strings/ctype-uca.c22
-rw-r--r--strings/decimal.c4
2 files changed, 24 insertions, 2 deletions
diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c
index b3a7c6afde9..60bd96e499d 100644
--- a/strings/ctype-uca.c
+++ b/strings/ctype-uca.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004, 2013, Oracle and/or its affiliates.
- Copyright (c) 2009, 2014, SkySQL Ab.
+ Copyright (c) 2009, 2015, MariaDB
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
@@ -20583,7 +20583,25 @@ static int my_uca_scanner_next_any(my_uca_scanner *scanner)
if (((mblen= scanner->cs->cset->mb_wc(scanner->cs, wc,
scanner->sbeg,
scanner->send)) <= 0))
- return -1;
+ {
+ if (scanner->sbeg >= scanner->send)
+ return -1; /* No more bytes, end of line reached */
+ /*
+ There are some more bytes left. Non-positive mb_len means that
+ we got an incomplete or a bad byte sequence. Consume mbminlen bytes.
+ */
+ if ((scanner->sbeg+= scanner->cs->mbminlen) > scanner->send)
+ {
+ /* For safety purposes don't go beyond the string range. */
+ scanner->sbeg= scanner->send;
+ }
+ /*
+ Treat every complete or incomplete mbminlen unit as a weight which is
+ greater than weight for any possible normal character.
+ 0xFFFF is greater than any possible weight in the UCA weight table.
+ */
+ return 0xFFFF;
+ }
scanner->sbeg+= mblen;
if (wc[0] > scanner->level->maxchar)
diff --git a/strings/decimal.c b/strings/decimal.c
index 979f1b179f9..da47727bd9c 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -1024,7 +1024,11 @@ int ulonglong2decimal(ulonglong from, decimal_t *to)
int longlong2decimal(longlong from, decimal_t *to)
{
if ((to->sign= from < 0))
+ {
+ if (from == LONGLONG_MIN) // avoid undefined behavior
+ return ull2dec((ulonglong)LONGLONG_MIN, to);
return ull2dec(-from, to);
+ }
return ull2dec(from, to);
}