Skip to content

Commit 669a02b

Browse files
committed
find bugs: fix key comparison when key is string and == is used
1 parent 8b0322a commit 669a02b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/nodes/attributes/WriteAttributeToDynamicObjectNode.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ public static WriteAttributeToDynamicObjectNode create() {
6565
return WriteAttributeToDynamicObjectNodeGen.create();
6666
}
6767

68+
protected static boolean compareKey(Object cachedKey, Object key) {
69+
return cachedKey == key;
70+
}
71+
6872
@SuppressWarnings("unused")
6973
@Specialization(guards = {
7074
"dynamicObject.getShape() == cachedShape",
@@ -82,7 +86,7 @@ protected boolean updateShapeAndWrite(DynamicObject dynamicObject, Object key, O
8286
@Specialization(limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)", //
8387
guards = {
8488
"dynamicObject.getShape() == cachedShape",
85-
"cachedKey == key",
89+
"compareKey(cachedKey, key)",
8690
"loc != null",
8791
"loc.canSet(value)"
8892
}, //
@@ -110,7 +114,7 @@ protected boolean doDirect(DynamicObject dynamicObject, Object key, Object value
110114
@Specialization(limit = "getIntOption(getContext(), AttributeAccessInlineCacheMaxDepth)", //
111115
guards = {
112116
"dynamicObject.getShape() == cachedShape",
113-
"cachedKey == key",
117+
"compareKey(cachedKey, key)",
114118
"loc == null || !loc.canSet(value)",
115119
"newLoc.canSet(value)"
116120
}, //

0 commit comments

Comments
 (0)