Merge branch 'master' into master
diff --git a/c/dec/decode.c b/c/dec/decode.c
index c4972a5..5510d10 100644
--- a/c/dec/decode.c
+++ b/c/dec/decode.c
@@ -481,6 +481,9 @@
uint8_t* ringbuffer,
int pos,
const int limit) {
+ const int kMaximalOverread = 4;
+ int pos_limit = limit;
+ int copies = 0;
/* Calculate range where CheckInputAmount is always true.
Start with the number of bytes we can read. */
int64_t new_lim = br->guard_in - br->next_in;
@@ -488,9 +491,6 @@
new_lim *= 8;
/* At most 15 bits per symbol, so this is safe. */
new_lim /= 15;
- const int kMaximalOverread = 4;
- int pos_limit = limit;
- int copies = 0;
if ((new_lim - kMaximalOverread) <= limit) {
// Safe cast, since new_lim is already < num_steps
pos_limit = (int)(new_lim - kMaximalOverread);
@@ -2091,10 +2091,10 @@
} while (--i != 0);
} else { /* safe */
do {
+ brotli_reg_t literal;
if (BROTLI_PREDICT_FALSE(s->block_length[0] == 0)) {
goto NextLiteralBlock;
}
- brotli_reg_t literal;
if (!SafeReadSymbol(s->literal_htree, br, &literal)) {
result = BROTLI_DECODER_NEEDS_MORE_INPUT;
goto saveStateAndReturn;
diff --git a/c/enc/encode.c b/c/enc/encode.c
index 9e72744..b2583e4 100644
--- a/c/enc/encode.c
+++ b/c/enc/encode.c
@@ -761,11 +761,12 @@
BrotliEncoderState* BrotliEncoderCreateInstance(
brotli_alloc_func alloc_func, brotli_free_func free_func, void* opaque) {
+ BrotliEncoderState* state;
BROTLI_BOOL healthy = BrotliEncoderEnsureStaticInit();
if (!healthy) {
return 0;
}
- BrotliEncoderState* state = (BrotliEncoderState*)BrotliBootstrapAlloc(
+ state = (BrotliEncoderState*)BrotliBootstrapAlloc(
sizeof(BrotliEncoderState), alloc_func, free_func, opaque);
if (state == NULL) {
/* BROTLI_DUMP(); */