Skip to content

Verilator/SDL Screen Array Unchecked (C++) #90

@WillGreen

Description

@WillGreen

We don't check the SDL/Verilator screenbuffer array index is valid.

Pixel screenbuffer[H_RES*V_RES];

// update pixel if not in blanking interval
if (top->sdl_de) {
      Pixel* p = &screenbuffer[top->sdl_sy*H_RES + top->sdl_sx];
      p->a = 0xFF;  // transparency
      p->b = top->sdl_b;
      p->g = top->sdl_g;
      p->r = top->sdl_r;
  }

An invalid index will corrupt the simulation or (more likely) cause a core dump.

The display signals module should never set sdl_de high with an invalid sdl_sy or sdl_sx, but we shouldn't assume this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions