diff --git generic/tclEncoding.c generic/tclEncoding.c
index 92217f3327..91a6fb85eb 100644
--- generic/tclEncoding.c
+++ generic/tclEncoding.c
@@ -2151,7 +2151,9 @@ BinaryProc(
     *srcReadPtr = srcLen;
     *dstWrotePtr = srcLen;
     *dstCharsPtr = srcLen;
-    memcpy(dst, src, srcLen);
+    if (NULL != src) {
+	memcpy(dst, src, srcLen);
+    }
     return result;
 }
 
@@ -2312,7 +2314,7 @@ UtfToUtfProc(
     result = TCL_OK;
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
     srcClose = srcEnd;
     if ((flags & TCL_ENCODING_END) == 0) {
 	srcClose -= 6;
@@ -2324,7 +2326,7 @@ UtfToUtfProc(
     dstStart = dst;
     dstEnd = dst + dstLen - ((pureNullMode == 1) ? 4 : TCL_UTF_MAX);
 
-    for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd && numChars <= charLimit; numChars++) {
 	if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
 	    /*
 	     * If there is more string to follow, this will ensure that the
@@ -2412,7 +2414,7 @@ UtfToUtfProc(
 	}
     }
 
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -2494,12 +2496,12 @@ UnicodeToUtfProc(
 #endif
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
 
     dstStart = dst;
     dstEnd = dst + dstLen - TCL_UTF_MAX;
 
-    for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd && numChars <= charLimit; numChars++) {
 	if (dst > dstEnd) {
 	    result = TCL_CONVERT_NOSPACE;
 	    break;
@@ -2536,7 +2538,7 @@ UnicodeToUtfProc(
 	    src++;
 	}
     }
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -2593,7 +2595,7 @@ UtfToUnicodeProc(
     	*statePtr = 0;
     }
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
     srcClose = srcEnd;
     if ((flags & TCL_ENCODING_END) == 0) {
 	srcClose -= TCL_UTF_MAX;
@@ -2603,7 +2605,7 @@ UtfToUnicodeProc(
     dstEnd   = dst + dstLen - sizeof(Tcl_UniChar);
 
     result = TCL_OK;
-    for (numChars = 0; src < srcEnd; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd; numChars++) {
 	if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
 	    /*
 	     * If there is more string to follow, this will ensure that the
@@ -2651,7 +2653,7 @@ UtfToUnicodeProc(
 #endif
 	}
     }
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -2714,7 +2716,7 @@ TableToUtfProc(
 	charLimit = *dstCharsPtr;
     }
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
 
     dstStart = dst;
     dstEnd = dst + dstLen - TCL_UTF_MAX;
@@ -2724,7 +2726,7 @@ TableToUtfProc(
     pageZero = toUnicode[0];
 
     result = TCL_OK;
-    for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd && numChars <= charLimit; numChars++) {
 	if (dst > dstEnd) {
 	    result = TCL_CONVERT_NOSPACE;
 	    break;
@@ -2764,7 +2766,7 @@ TableToUtfProc(
 	src++;
     }
 
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -2828,7 +2830,7 @@ TableFromUtfProc(
     fromUnicode = (const unsigned short *const *) dataPtr->fromUnicode;
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
     srcClose = srcEnd;
     if ((flags & TCL_ENCODING_END) == 0) {
 	srcClose -= TCL_UTF_MAX;
@@ -2837,7 +2839,7 @@ TableFromUtfProc(
     dstStart = dst;
     dstEnd = dst + dstLen - 1;
 
-    for (numChars = 0; src < srcEnd; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd; numChars++) {
 	if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
 	    /*
 	     * If there is more string to follow, this will ensure that the
@@ -2887,7 +2889,7 @@ TableFromUtfProc(
 	src += len;
     }
 
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -2944,13 +2946,13 @@ Iso88591ToUtfProc(
 	charLimit = *dstCharsPtr;
     }
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
 
     dstStart = dst;
     dstEnd = dst + dstLen - TCL_UTF_MAX;
 
     result = TCL_OK;
-    for (numChars = 0; src < srcEnd && numChars <= charLimit; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd && numChars <= charLimit; numChars++) {
 	Tcl_UniChar ch = 0;
 
 	if (dst > dstEnd) {
@@ -2971,7 +2973,7 @@ Iso88591ToUtfProc(
 	src++;
     }
 
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -3026,7 +3028,7 @@ Iso88591FromUtfProc(
     Tcl_UniChar ch = 0;
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
     srcClose = srcEnd;
     if ((flags & TCL_ENCODING_END) == 0) {
 	srcClose -= TCL_UTF_MAX;
@@ -3035,7 +3037,7 @@ Iso88591FromUtfProc(
     dstStart = dst;
     dstEnd = dst + dstLen - 1;
 
-    for (numChars = 0; src < srcEnd; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd; numChars++) {
 	int len;
 
 	if ((src > srcClose) && (!Tcl_UtfCharComplete(src, srcEnd - src))) {
@@ -3082,7 +3084,7 @@ Iso88591FromUtfProc(
 	src += len;
     }
 
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -3185,7 +3187,7 @@ EscapeToUtfProc(
     encodingPtr = NULL;
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
 
     dstStart = dst;
     dstEnd = dst + dstLen - TCL_UTF_MAX;
@@ -3195,7 +3197,7 @@ EscapeToUtfProc(
 	state = 0;
     }
 
-    for (numChars = 0; src < srcEnd && numChars <= charLimit; ) {
+    for (numChars = 0; (NULL != src) && src < srcEnd && numChars <= charLimit; ) {
 	int byte, hi, lo, ch;
 
 	if (dst > dstEnd) {
@@ -3331,7 +3333,7 @@ EscapeToUtfProc(
     }
 
     *statePtr = (Tcl_EncodingState) INT2PTR(state);
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
@@ -3395,7 +3397,7 @@ EscapeFromUtfProc(
     result = TCL_OK;
 
     srcStart = src;
-    srcEnd = src + srcLen;
+    srcEnd = (NULL != src) ? (src + srcLen) : NULL;
     srcClose = srcEnd;
     if ((flags & TCL_ENCODING_END) == 0) {
 	srcClose -= TCL_UTF_MAX;
@@ -3428,7 +3430,7 @@ EscapeFromUtfProc(
     tableFromUnicode = (const unsigned short *const *)
 	    tableDataPtr->fromUnicode;
 
-    for (numChars = 0; src < srcEnd; numChars++) {
+    for (numChars = 0; (NULL != src) && src < srcEnd; numChars++) {
 	unsigned len;
 	int word;
 
@@ -3544,7 +3546,7 @@ EscapeFromUtfProc(
     }
 
     *statePtr = (Tcl_EncodingState) INT2PTR(state);
-    *srcReadPtr = src - srcStart;
+    *srcReadPtr = (NULL != src) ? (src - srcStart) : 0;
     *dstWrotePtr = dst - dstStart;
     *dstCharsPtr = numChars;
     return result;
