Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate lines in plm_buffer_has method #11

Closed
yasoob opened this issue Jul 17, 2020 · 1 comment
Closed

Duplicate lines in plm_buffer_has method #11

yasoob opened this issue Jul 17, 2020 · 1 comment

Comments

@yasoob
Copy link

yasoob commented Jul 17, 2020

There seem to be some duplicate lines in plm_buffer_has method:

int plm_buffer_has(plm_buffer_t *self, size_t count) {
	if (((self->length << 3) - self->bit_index) >= count) {
		return TRUE;
	}

	if (self->load_callback) {
		self->load_callback(self, self->load_callback_user_data);
	}

	if (((self->length << 3) - self->bit_index) >= count) {
		return TRUE;
	}
	
	if (self->total_size != 0 && self->length == self->total_size) {
		self->has_ended = TRUE;
	}
	return FALSE;
}
@phoboslab
Copy link
Owner

This is correct, because the load_callback() may be called in between those checks and it may or may not have loaded enough bytes, so we have to check again.

The second check could be moved into the if (self->load_callback) { ... } though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants