Subject k5_utf8s_to_ucs2s could deref NULL pointer..
authorEzra Peisach <epeisach@mit.edu>
Tue, 7 Apr 2009 23:59:25 +0000 (23:59 +0000)
committerEzra Peisach <epeisach@mit.edu>
Tue, 7 Apr 2009 23:59:25 +0000 (23:59 +0000)
Based on usage of this static function, this will never happen as
results are always malloced (and checked) by caller.  However, the
function is already coded to handle the first argument being null - so
be consistent throughout.

ticket:

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22177 dc483132-0cff-0310-8789-dd5450dbe970

src/util/support/utf8_conv.c

index 58fb25022ea423822f93dcee3ef26d91b7c8fe08..f8e4a496bc5f465435a7446c73619b92f0d65977 100644 (file)
@@ -119,9 +119,11 @@ k5_utf8s_to_ucs2s(krb5_ucs2 *ucs2str,
     }
 
     assert(ucs2len < count);
-
-    /* Add null terminator if there's room in the buffer. */
-    ucs2str[ucs2len] = 0;
+    
+    if (ucs2str != NULL) {
+       /* Add null terminator if there's room in the buffer. */
+       ucs2str[ucs2len] = 0;
+    }
 
     return ucs2len;
 }