Commit 9115ea4
committed
libscript: Prevent null dereference on error when property has no getter
The `MCScriptGetTypeOfPropertyInModule()` function could deference a
null pointer when attempting to determine the get type for the
specified property. This function was only used in the
`MCScriptThrowInvalidValueForPropertyError()` error dispatch helper,
which in turn was only used from contexts where the VM had already
resolved a specific type for the property and had _just_ failed to
compare a value with it.
This patch removes the `MCScriptGetTypeOfPropertyInModule()` function
entirely, and refactors `MCScriptThrowInvalidValueForPropertyError()`
to take the failed property type as an argument.
By doing so it also corrects another bug: when the type required when
setting a property is different from the type obtained by getting the
property, the error message when failing to set the property would be
misleading.
Coverity-Id: 1379241 parent ae3097b commit 9115ea4
File tree
4 files changed
+4
-37
lines changed- libscript/src
4 files changed
+4
-37
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
| |||
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
70 | | - | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
| 418 | + | |
418 | 419 | | |
419 | 420 | | |
420 | 421 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1096 | 1096 | | |
1097 | 1097 | | |
1098 | 1098 | | |
1099 | | - | |
1100 | | - | |
1101 | | - | |
1102 | | - | |
1103 | | - | |
1104 | | - | |
1105 | | - | |
1106 | | - | |
1107 | | - | |
1108 | | - | |
1109 | | - | |
1110 | | - | |
1111 | | - | |
1112 | | - | |
1113 | | - | |
1114 | | - | |
1115 | | - | |
1116 | | - | |
1117 | | - | |
1118 | | - | |
1119 | | - | |
1120 | | - | |
1121 | | - | |
1122 | | - | |
1123 | | - | |
1124 | | - | |
1125 | | - | |
1126 | | - | |
1127 | | - | |
1128 | | - | |
1129 | | - | |
1130 | | - | |
1131 | | - | |
1132 | | - | |
1133 | 1099 | | |
1134 | 1100 | | |
1135 | 1101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | 409 | | |
411 | 410 | | |
412 | 411 | | |
| |||
486 | 485 | | |
487 | 486 | | |
488 | 487 | | |
| 488 | + | |
489 | 489 | | |
490 | 490 | | |
491 | 491 | | |
| |||
0 commit comments