krb5 commit: Initialize outpos in krb5int_utf8_normalize

Greg Hudson ghudson at MIT.EDU
Tue Apr 9 12:28:58 EDT 2013


https://github.com/krb5/krb5/commit/893a178cbdc03ee9d1936c95a3f567cb2796420d
commit 893a178cbdc03ee9d1936c95a3f567cb2796420d
Author: Greg Hudson <ghudson at mit.edu>
Date:   Tue Apr 9 11:43:54 2013 -0400

    Initialize outpos in krb5int_utf8_normalize
    
    After k5memdup0 was slightly modified in
    31124ffb81e8c0935403a9fdc169dead5ecaa777, some older versions of gcc
    complain about outpos being possibly used before it is initialized.
    This can't actually happen, but we can silence the error and also
    simplify how outpos is initialized.

 src/lib/krb5/unicode/ucstr.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

diff --git a/src/lib/krb5/unicode/ucstr.c b/src/lib/krb5/unicode/ucstr.c
index 38d8d47..ea96335 100644
--- a/src/lib/krb5/unicode/ucstr.c
+++ b/src/lib/krb5/unicode/ucstr.c
@@ -109,7 +109,7 @@ krb5int_utf8_normalize(
 		       krb5_data ** newdataptr,
 		       unsigned flags)
 {
-    int i, j, len, clen, outpos, ucsoutlen, outsize;
+    int i, j, len, clen, outpos = 0, ucsoutlen, outsize;
     char *out = NULL, *outtmp, *s;
     krb5_ucs4 *ucs = NULL, *p, *ucsout = NULL;
     krb5_data *newdata;
@@ -144,7 +144,6 @@ krb5int_utf8_normalize(
 		retval = ENOMEM;
 		goto cleanup;
 	    }
-	    outpos = 0;
 
 	    for (i = 1; (i < len) && KRB5_UTF8_ISASCII(s + i); i++) {
 		out[outpos++] = TOLOWER(s[i - 1]);
@@ -182,7 +181,6 @@ krb5int_utf8_normalize(
 	    retval = ENOMEM;
 	    goto cleanup;
 	}
-	outpos = 0;
 	i = 0;
     }
 


More information about the cvs-krb5 mailing list