summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Wagner <bungeman@chromium.org>2021-02-12 14:51:43 -0500
committerBen Wagner <bungeman@chromium.org>2021-02-16 11:30:32 -0500
commitba15d41bdc0f6e949089d71208f8afdc99e1d19b (patch)
tree05a27d25809c1da7b5dcf4a7ae62064a00f3a40c /src
parentae9ac2a1bfb6fa800b99791b6fc36711dd0c1fbc (diff)
downloadfontconfig-ba15d41bdc0f6e949089d71208f8afdc99e1d19b.tar.gz
Fix stack use after scope in FcConfigCompareValue
Discovered by AddressSanitizer. When left_o and right_o are promoted the promoted values are placed on the stack in FcValuePromotionBuffer. The FcValuePromotionBuffers must then continue to be in scope while left_o and right_o point into their content. In 9d4e5d0f the FcValuePromotionBuffers were moved into the incorrect scope, leaving left_o and right_o pointing into an object whose lifetime has ended. This is similar to left and right which appear to have a smaller scope but are actually required to be in the larger scope. Correct this by moving the FcValuePromotionBuffers to the proper scope. Leave the left and right FcValues where they are since they are in the correct scope already. This also adds to test-conf the ability to create charset, langset, range, and matrix in patterns. This allows for a simple test which fails under AddressSanitizer before this change and passes after.
Diffstat (limited to 'src')
-rw-r--r--src/fccfg.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/fccfg.c b/src/fccfg.c
index 91af959..462c423 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -989,12 +989,12 @@ FcConfigCompareValue (const FcValue *left_o,
FcBool ret = FcFalse;
FcOp op = FC_OP_GET_OP (op_);
int flags = FC_OP_GET_FLAGS (op_);
+ FcValuePromotionBuffer buf1, buf2;
if (left_o->type != right_o->type)
{
left = FcValueCanonicalize(left_o);
right = FcValueCanonicalize(right_o);
- FcValuePromotionBuffer buf1, buf2;
left = FcConfigPromote (left, right, &buf1);
right = FcConfigPromote (right, left, &buf2);
left_o = &left;