]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
ucp_table: don't always deref rv of lower_bound
authorJustin Viiret <justin.viiret@intel.com>
Mon, 9 May 2016 06:03:39 +0000 (16:03 +1000)
committerMatthew Barr <matthew.barr@intel.com>
Wed, 18 May 2016 06:28:17 +0000 (16:28 +1000)
Fixes a warning from asan.

src/parser/ucp_table.cpp

index 7b53d1d6a897ad1610befeb696743cd4785efa10..a6cb57cdd463b892a0a827b86b00fcc730a7c856 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Intel Corporation
+ * Copyright (c) 2015-2016, Intel Corporation
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are met:
@@ -117,13 +117,12 @@ void make_caseless(CodePointSet *cps) {
 bool flip_case(unichar *c) {
     assert(c);
 
-    const unicase *const uc_begin = ucp_caseless_def;
-    const unicase *const uc_end =
-        ucp_caseless_def + ARRAY_LENGTH(ucp_caseless_def);
-
     const unicase test = { *c, 0 };
-    const unicase *f = lower_bound(uc_begin, uc_end, test);
-    if (f->base == *c) {
+
+    const auto uc_begin = begin(ucp_caseless_def);
+    const auto uc_end = end(ucp_caseless_def);
+    const auto f = lower_bound(uc_begin, uc_end, test);
+    if (f != uc_end && f->base == *c) {
         DEBUG_PRINTF("flipped c=%x to %x\n", *c, f->caseless);
         *c = f->caseless;
         return true;