Skip to content

Commit

Permalink
Do not add userphrase whe auto commit
Browse files Browse the repository at this point in the history
We does not know if the whole auto commit string is a valid phrase. It
might contain symbol. Also, it causes memory leak due to mismatch
phoneSeq and wordSeq.

Closed #80
  • Loading branch information
czchen committed Sep 19, 2013
1 parent 6b84a18 commit 79ba8da
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/chewingutil.c
Expand Up @@ -537,8 +537,6 @@ void CleanAllBuf( ChewingData *pgdata )
int ReleaseChiSymbolBuf( ChewingData *pgdata, ChewingOutput *pgo )
{
int throwEnd;
uint16_t bufPhoneSeq[ MAX_PHONE_SEQ_LEN + 1 ];
char bufWordSeq[ MAX_PHONE_SEQ_LEN * MAX_UTF8_SIZE + 1 ];

throwEnd = CountReleaseNum( pgdata );

Expand All @@ -550,11 +548,10 @@ int ReleaseChiSymbolBuf( ChewingData *pgdata, ChewingOutput *pgo )
*/
WriteChiSymbolToBuf( pgo->commitStr, throwEnd, pgdata );

/* Add to userphrase */
memcpy( bufPhoneSeq, pgdata->phoneSeq, sizeof( uint16_t ) * throwEnd );
bufPhoneSeq[ throwEnd ] = (uint16_t) 0;
ueStrNCpy( bufWordSeq, pgdata->phrOut.chiBuf, throwEnd, 1 );
UserUpdatePhrase( pgdata, bufPhoneSeq, bufWordSeq );
/*
* FIXME: analyze auto commit string and update userphrase
* according to it.
*/

KillFromLeft( pgdata, throwEnd );
}
Expand Down

0 comments on commit 79ba8da

Please sign in to comment.