Fix potential null pointer dereference
utf8_encoder() was incorrectly dereferencing the pointer `state' before testing it against null; fix by removing the variable initialisers.
This commit is contained in:
parent
0275295c88
commit
3cfd83e1a6
|
@ -10,8 +10,7 @@
|
|||
struct utf8_encode_state*
|
||||
utf8_encoder(struct utf8_encode_state* state)
|
||||
{
|
||||
char* wr = state->wr, * ret;
|
||||
char* endp = wr + state->wr_size - 1;
|
||||
char* wr, * ret, * endp;
|
||||
wchar_t ch;
|
||||
enum utf8_encode_error_action error_action;
|
||||
int reencoding;
|
||||
|
@ -21,6 +20,9 @@ utf8_encoder(struct utf8_encode_state* state)
|
|||
return 0;
|
||||
}
|
||||
|
||||
wr = state->wr;
|
||||
endp = wr + state->wr_size - 1;
|
||||
|
||||
state->written = 0;
|
||||
while(state->rd_remain) {
|
||||
ch = *state->rd;
|
||||
|
|
Loading…
Reference in New Issue