java-topology/defects/nestopia-scan/CLEAN.md

1.6 KiB

Nestopia UE — 5-MOAD Scan — CLEAN

Target: Nestopia UE (NES emulator, C++) Source: https://github.com/0ldsk00l/nestopia Scan date: 2026-03-31 Scanner: agent blackops

Results

MOAD Pattern Result Notes
0001 CWE-407: list/array membership inside loop CLEAN All hot paths use maps/binary_search
0002 Intertangle: shared mutable global state CLEAN Machine composition is expected emulator design
0003 Leaked Context: ThreadLocal request-scoped CLEAN No threading in emulator core
0004 CWE-312: credentials logged verbatim CLEAN No network stack
0005 Thundering Herd: cache get+null+put without sync CLEAN No concurrent caches

MOAD-0001 Detail

Scan covered:

  • source/core/NstCpu.cpp — CPU instruction execution loop: no list membership tests
  • source/core/NstApu.cpp — APU channel loop: fixed-size constant loops only
  • source/core/NstPpu.cpp — PPU scanline/sprite: fixed-size OAM buffer (64 sprites max)
  • source/core/NstCheats.cppBeginFrame(): linear scan over cheat codes but O(C) per frame, not O(N²); insertion uses sorted insert + std::lower_bound (O(log N))
  • source/core/board/NstBoard.cpp — mapper lookup: std::lower_bound on sorted LUT (O(log N))
  • source/core/NstImageDatabase.cpp — ROM DB lookup: std::lower_bound (O(log N))
  • source/win32/NstDirectInput.cpp — Input polling: maps keyed on device+button, O(1) per event
  • source/fltkui/inputmanager.cpp — Input events: kbmap, jxmap, jamap, jbmap std::map, O(1)

No O(N²) pattern found in any hot path (per-instruction, per-scanline, or per-frame).