@@ -149,6 +149,11 @@ impl LocalBacking {
149
149
} ] ) ;
150
150
}
151
151
Initializer :: GetGlobal ( import_global_index) => {
152
+ if import_global_index. index ( ) >= imports. globals . len ( ) {
153
+ return Err ( vec ! [ LinkError :: Generic {
154
+ message: "incorrect global index for initializer" . to_string( ) ,
155
+ } ] ) ;
156
+ }
152
157
if let Value :: I32 ( x) = imports. globals [ import_global_index] . get ( ) {
153
158
x as u32
154
159
} else {
@@ -205,6 +210,11 @@ impl LocalBacking {
205
210
} ] ) ;
206
211
}
207
212
Initializer :: GetGlobal ( import_global_index) => {
213
+ if import_global_index. index ( ) >= imports. globals . len ( ) {
214
+ return Err ( vec ! [ LinkError :: Generic {
215
+ message: "incorrect global index for initializer" . to_string( ) ,
216
+ } ] ) ;
217
+ }
208
218
if let Value :: I32 ( x) = imports. globals [ import_global_index] . get ( ) {
209
219
x as u32
210
220
} else {
@@ -273,6 +283,11 @@ impl LocalBacking {
273
283
} ] ) ;
274
284
}
275
285
Initializer :: GetGlobal ( import_global_index) => {
286
+ if import_global_index. index ( ) >= imports. globals . len ( ) {
287
+ return Err ( vec ! [ LinkError :: Generic {
288
+ message: "incorrect global index for initializer" . to_string( ) ,
289
+ } ] ) ;
290
+ }
276
291
if let Value :: I32 ( x) = imports. globals [ import_global_index] . get ( ) {
277
292
x as u32
278
293
} else {
@@ -326,6 +341,11 @@ impl LocalBacking {
326
341
} ] ) ;
327
342
}
328
343
Initializer :: GetGlobal ( import_global_index) => {
344
+ if import_global_index. index ( ) >= imports. globals . len ( ) {
345
+ return Err ( vec ! [ LinkError :: Generic {
346
+ message: "incorrect global index for initializer" . to_string( ) ,
347
+ } ] ) ;
348
+ }
329
349
if let Value :: I32 ( x) = imports. globals [ import_global_index] . get ( ) {
330
350
x as u32
331
351
} else {
0 commit comments