| 336 | } |
| 337 | |
| 338 | class Reader { |
| 339 | constructor(rstr, rstr_view) { |
| 340 | this.rstr = rstr; |
| 341 | this.rstr_view = rstr_view; |
| 342 | this.m_data = rstr_view.read64(off.strimpl_m_data); |
| 343 | } |
| 344 | |
| 345 | read8_at(offset) { |
| 346 | return this.rstr.charCodeAt(offset); |
| 347 | } |
| 348 | |
| 349 | read32_at(offset) { |
| 350 | const str = this.rstr; |
| 351 | return (str.charCodeAt(offset) | (str.charCodeAt(offset + 1) << 8) | (str.charCodeAt(offset + 2) << 16) | (str.charCodeAt(offset + 3) << 24)) >>> 0; |
| 352 | } |
| 353 | |
| 354 | read64_at(offset) { |
| 355 | return sread64(this.rstr, offset); |
| 356 | } |
| 357 | |
| 358 | read64(addr) { |
| 359 | this.rstr_view.write64(off.strimpl_m_data, addr); |
| 360 | return sread64(this.rstr, 0); |
| 361 | } |
| 362 | |
| 363 | set_addr(addr) { |
| 364 | this.rstr_view.write64(off.strimpl_m_data, addr); |
| 365 | } |
| 366 | |
| 367 | // remember to use this to fix up the StringImpl before freeing it |
| 368 | restore() { |
| 369 | this.rstr_view.write64(off.strimpl_m_data, this.m_data); |
| 370 | this.rstr_view.write32(off.strimpl_strlen, original_strlen); |
| 371 | } |
| 372 | } |
| 373 | |
| 374 | // we now have a double free on the fastMalloc heap |
| 375 | async function make_rdr(view) { |
nothing calls this directly
no outgoing calls
no test coverage detected