diff options
author | Tom Anderson <thomasanderson@chromium.org> | 2018-04-11 11:39:56 -0700 |
---|---|---|
committer | Behdad Esfahbod <behdad@behdad.org> | 2018-04-16 15:23:20 +0200 |
commit | c60ed9ef66e59584f8b54323018e9e6c69925c7e (patch) | |
tree | 51f5e68cbaa99a056bdff8d7c922d30d30843ca6 /src/fclang.c | |
parent | a8a6efa805fc03e790214e8a0bc55843a258d774 (diff) | |
download | fontconfig-c60ed9ef66e59584f8b54323018e9e6c69925c7e.tar.gz |
Fix undefined-shift UBSAN errors
The expression "1 << 31" will cause UBSAN to complain with this error message:
runtime error: left shift of 1 by 31 places cannot be represented in type 'int'
The same operation on unsigned types is fine, however. This CL replaces the
strings "1 <<" with "1U <<".
Diffstat (limited to 'src/fclang.c')
-rw-r--r-- | src/fclang.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/fclang.c b/src/fclang.c index eadf34b..687e2a7 100644 --- a/src/fclang.c +++ b/src/fclang.c @@ -59,7 +59,7 @@ FcLangSetBitSet (FcLangSet *ls, if (bucket >= ls->map_size) return; /* shouldn't happen really */ - ls->map[bucket] |= ((FcChar32) 1 << (id & 0x1f)); + ls->map[bucket] |= ((FcChar32) 1U << (id & 0x1f)); } static FcBool @@ -87,7 +87,7 @@ FcLangSetBitReset (FcLangSet *ls, if (bucket >= ls->map_size) return; /* shouldn't happen really */ - ls->map[bucket] &= ~((FcChar32) 1 << (id & 0x1f)); + ls->map[bucket] &= ~((FcChar32) 1U << (id & 0x1f)); } FcLangSet * @@ -157,7 +157,7 @@ FcFreeTypeLangSet (const FcCharSet *charset, if (map[i]) { for (j = 0; j < 32; j++) - if (map[i] & (1 << j)) + if (map[i] & (1U << j)) printf (" %04x", ucs4 + i * 32 + j); } } @@ -848,7 +848,7 @@ FcNameUnparseLangSet (FcStrBuf *buf, const FcLangSet *ls) if ((bits = ls->map[i])) { for (bit = 0; bit <= 31; bit++) - if (bits & (1 << bit)) + if (bits & (1U << bit)) { int id = (i << 5) | bit; if (!first) @@ -982,7 +982,7 @@ FcLangSetContains (const FcLangSet *lsa, const FcLangSet *lsb) if (missing) { for (j = 0; j < 32; j++) - if (missing & (1 << j)) + if (missing & (1U << j)) { if (!FcLangSetContainsLang (lsa, fcLangCharSets[fcLangCharSetIndicesInv[i*32 + j]].lang)) |