@@ -924,7 +924,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
924
924
char charset [129 ];
925
925
char encoding [33 ];
926
926
char dummy [129 ];
927
- char * ptr ;
927
+ char * ptr , * endptr ;
928
928
char * old_output ;
929
929
930
930
#ifdef NOTUSED
@@ -959,6 +959,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
959
959
960
960
if (!strcasecmp ("q" , encoding )) {
961
961
/* quoted printable decoding */
962
+ endptr = ptr + strlen (ptr );
962
963
963
964
#ifdef HAVE_ICONV
964
965
char * orig2 ,* output2 ,* output3 ;
@@ -967,7 +968,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
967
968
memset (output2 ,0 ,strlen (string )+ 1 );
968
969
old_output = output ;
969
970
970
- for (; * ptr ; ptr ++ ) {
971
+ for (; ptr < endptr ; ptr ++ ) {
971
972
switch (* ptr ) {
972
973
case '=' :
973
974
sscanf (ptr + 1 , "%02X" , & value );
@@ -991,7 +992,7 @@ static char *mdecodeRFC2047(char *string, int length, char *charsetsave)
991
992
memcpy (charsetsave ,charset ,charsetlen );
992
993
charsetsave [charsetlen ] = '\0' ;
993
994
#else
994
- for (; * ptr ; ptr ++ ) {
995
+ for (; ptr < endptr ; ptr ++ ) {
995
996
switch (* ptr ) {
996
997
case '=' :
997
998
sscanf (ptr + 1 , "%02X" , & value );
@@ -2378,6 +2379,7 @@ int parsemail(char *mbox, /* file name */
2378
2379
#endif
2379
2380
if (charset ) {
2380
2381
free (charset );
2382
+ charset = NULL ;
2381
2383
}
2382
2384
charsetsave [0 ] = '\0' ;
2383
2385
0 commit comments