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:
Laurence Withers 2009-11-03 23:08:55 +00:00
parent 0275295c88
commit 3cfd83e1a6
1 changed files with 4 additions and 2 deletions

View File

@ -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;