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*
|
struct utf8_encode_state*
|
||||||
utf8_encoder(struct utf8_encode_state* state)
|
utf8_encoder(struct utf8_encode_state* state)
|
||||||
{
|
{
|
||||||
char* wr = state->wr, * ret;
|
char* wr, * ret, * endp;
|
||||||
char* endp = wr + state->wr_size - 1;
|
|
||||||
wchar_t ch;
|
wchar_t ch;
|
||||||
enum utf8_encode_error_action error_action;
|
enum utf8_encode_error_action error_action;
|
||||||
int reencoding;
|
int reencoding;
|
||||||
|
@ -21,6 +20,9 @@ utf8_encoder(struct utf8_encode_state* state)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wr = state->wr;
|
||||||
|
endp = wr + state->wr_size - 1;
|
||||||
|
|
||||||
state->written = 0;
|
state->written = 0;
|
||||||
while(state->rd_remain) {
|
while(state->rd_remain) {
|
||||||
ch = *state->rd;
|
ch = *state->rd;
|
||||||
|
|
Loading…
Reference in New Issue