Blob Blame History Raw
diff --git a/lib/pkcs12/p12local.c b/lib/pkcs12/p12local.c
--- a/lib/pkcs12/p12local.c
+++ b/lib/pkcs12/p12local.c
@@ -923,17 +923,18 @@ sec_pkcs12_convert_item_to_unicode(PLAre
 	if(!arena) {
 	    PORT_Free(dest->data);
 	    dest->data = NULL;
 	    dest->len = 0;
 	}
 	return PR_FALSE;
     }
 
-    if((dest->data[dest->len-1] || dest->data[dest->len-2]) && zeroTerm) {
+    if ((dest->len >= 2) &&
+	(dest->data[dest->len-1] || dest->data[dest->len-2]) && zeroTerm) {
 	if(dest->len + 2 > 3 * src->len) {
 	    if(arena) {
 		dest->data = (unsigned char*)PORT_ArenaGrow(arena, 
 						     dest->data, dest->len,
 						     dest->len + 2);
 	    } else {
 		dest->data = (unsigned char*)PORT_Realloc(dest->data, 
 							  dest->len + 2);