several fixes
This commit is contained in:
parent
b1babd4b88
commit
75ca07fc8c
3 changed files with 38 additions and 7 deletions
|
|
@ -190,7 +190,7 @@ int sj4_from_utf16(u_char* out, const u_char* in, int len) {
|
|||
out += eucjp_write(out, n);
|
||||
}
|
||||
|
||||
return (out - o_out) * sizeof(wchar_t);
|
||||
return out - o_out;
|
||||
}
|
||||
|
||||
static u_int eucjp_read(const u_char* in) {
|
||||
|
|
@ -287,7 +287,7 @@ int sj4_to_utf16(u_char* out, const u_char* in, int len) {
|
|||
}
|
||||
}
|
||||
|
||||
return (w_out - o_out) * sizeof(wchar_t);
|
||||
return w_out - o_out;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
|
|||
len = sj4_charset_to(ctx->charset, ctx->wrk2buf, ctx->wrkbuf, len); \
|
||||
if(ctx->charset == SJ4UTF16) { \
|
||||
int i; \
|
||||
for(i = 0; i < sizeof(wchar_t); i++) ctx->wrk2buf[len * sizeof(wchar_t) + i] = 0; \
|
||||
((wchar_t*)ctx->wrk2buf)[len] = 0; \
|
||||
} else { \
|
||||
ctx->wrk2buf[len] = 0; \
|
||||
} \
|
||||
|
|
@ -64,6 +64,10 @@ Sj4Lib* sj4_open(int charset, const char* dic) {
|
|||
int sj4_getkan(Sj4Lib* ctx, const void* input, int len, Sj4Kouho* kouho) {
|
||||
int len2;
|
||||
|
||||
if(sizeof(ctx->inbuf) < (len * ((ctx->charset == SJ4UTF16 || ctx->charset == SJ4SJIS) ? sizeof(wchar_t) : 1))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(kouho, 0, sizeof(*kouho));
|
||||
ctx->kouho = kouho;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue