mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-24 12:30:17 +00:00
Various undefined behaviour fixes.
Primarily around uninitialised variables, but also with an attempted use of a negative pointer.
This commit is contained in:
parent
88959571f1
commit
edbc60a3fb
@ -155,18 +155,8 @@ class AYDeferrer {
|
||||
class CRTCBusHandler {
|
||||
public:
|
||||
CRTCBusHandler(uint8_t *ram, InterruptTimer &interrupt_timer) :
|
||||
cycles_(0),
|
||||
was_enabled_(false),
|
||||
was_sync_(false),
|
||||
pixel_data_(nullptr),
|
||||
pixel_pointer_(nullptr),
|
||||
was_hsync_(false),
|
||||
ram_(ram),
|
||||
interrupt_timer_(interrupt_timer),
|
||||
pixel_divider_(1),
|
||||
mode_(2),
|
||||
next_mode_(2),
|
||||
cycles_into_hsync_(0) {
|
||||
interrupt_timer_(interrupt_timer) {
|
||||
establish_palette_hits();
|
||||
build_mode_table();
|
||||
}
|
||||
@ -500,19 +490,19 @@ class CRTCBusHandler {
|
||||
return mapping[colour];
|
||||
}
|
||||
|
||||
unsigned int cycles_;
|
||||
unsigned int cycles_ = 0;
|
||||
|
||||
bool was_enabled_, was_sync_, was_hsync_, was_vsync_;
|
||||
int cycles_into_hsync_;
|
||||
bool was_enabled_ = false, was_sync_ = false, was_hsync_ = false, was_vsync_ = false;
|
||||
int cycles_into_hsync_ = 0;
|
||||
|
||||
std::shared_ptr<Outputs::CRT::CRT> crt_;
|
||||
uint8_t *pixel_data_, *pixel_pointer_;
|
||||
uint8_t *pixel_data_ = nullptr, *pixel_pointer_ = nullptr;
|
||||
|
||||
uint8_t *ram_;
|
||||
uint8_t *ram_ = nullptr;
|
||||
|
||||
int next_mode_, mode_;
|
||||
int next_mode_ = 2, mode_ = 2;
|
||||
|
||||
unsigned int pixel_divider_;
|
||||
unsigned int pixel_divider_ = 1;
|
||||
uint16_t mode0_output_[256];
|
||||
uint32_t mode1_output_[256];
|
||||
uint64_t mode2_output_[256];
|
||||
@ -522,9 +512,9 @@ class CRTCBusHandler {
|
||||
std::vector<uint8_t> mode1_palette_hits_[4];
|
||||
std::vector<uint8_t> mode3_palette_hits_[4];
|
||||
|
||||
int pen_;
|
||||
int pen_ = 0;
|
||||
uint8_t palette_[16];
|
||||
uint8_t border_;
|
||||
uint8_t border_ = 0;
|
||||
|
||||
InterruptTimer &interrupt_timer_;
|
||||
};
|
||||
|
@ -67,9 +67,7 @@ ArrayBuilder::Submission ArrayBuilder::submit() {
|
||||
}
|
||||
|
||||
ArrayBuilder::Buffer::Buffer(size_t size, std::function<void(bool is_input, uint8_t *, size_t)> submission_function) :
|
||||
is_full(false),
|
||||
submission_function_(submission_function),
|
||||
allocated_data(0), flushed_data(0), submitted_data(0) {
|
||||
submission_function_(submission_function) {
|
||||
if(!submission_function_) {
|
||||
glGenBuffers(1, &buffer);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
|
@ -82,17 +82,17 @@ class ArrayBuilder {
|
||||
void reset();
|
||||
|
||||
private:
|
||||
bool is_full;
|
||||
GLuint buffer;
|
||||
bool is_full = false;
|
||||
GLuint buffer = 0;
|
||||
std::function<void(bool is_input, uint8_t *, size_t)> submission_function_;
|
||||
std::vector<uint8_t> data;
|
||||
size_t allocated_data;
|
||||
size_t flushed_data;
|
||||
size_t submitted_data;
|
||||
size_t allocated_data = 0;
|
||||
size_t flushed_data = 0;
|
||||
size_t submitted_data = 0;
|
||||
} output_, input_;
|
||||
uint8_t *get_storage(size_t size, Buffer &buffer);
|
||||
|
||||
bool is_full_;
|
||||
bool is_full_ = false;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -99,13 +99,13 @@ void TextureBuilder::reduce_previous_allocation_to(size_t actual_length) {
|
||||
// against rounding errors when this run is drawn.
|
||||
// TODO: allow somebody else to specify the rule for generating a left-padding value and
|
||||
// a right-padding value.
|
||||
uint8_t *start_pointer = pointer_to_location(write_area_.x, write_area_.y);
|
||||
memcpy( &start_pointer[-bytes_per_pixel_],
|
||||
start_pointer,
|
||||
uint8_t *start_pointer = pointer_to_location(write_area_.x, write_area_.y) - bytes_per_pixel_;
|
||||
memcpy( start_pointer,
|
||||
&start_pointer[bytes_per_pixel_],
|
||||
bytes_per_pixel_);
|
||||
|
||||
memcpy( &start_pointer[actual_length * bytes_per_pixel_],
|
||||
&start_pointer[(actual_length - 1) * bytes_per_pixel_],
|
||||
memcpy( &start_pointer[(actual_length + 1) * bytes_per_pixel_],
|
||||
&start_pointer[actual_length * bytes_per_pixel_],
|
||||
bytes_per_pixel_);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user