]> git.sur5r.net Git - openldap/commitdiff
Apply patch suggested in ITS#2737 to address underallocation bug.
authorKurt Zeilenga <kurt@openldap.org>
Sun, 12 Oct 2003 23:31:00 +0000 (23:31 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Sun, 12 Oct 2003 23:31:00 +0000 (23:31 +0000)
This could should be reworked to avoid multiple reallocs (likely
by overallocating).

libraries/liblunicode/ucstr.c

index a8c65df8616e8de76045f0ad346dd01837e7eb69..d854b2aead48fc17fdba9632b88fe7f4f4111cd0 100644 (file)
@@ -251,6 +251,18 @@ struct berval * UTF8bvnormalize(
 
                last = i;
 
+               /* Allocate more space in out if necessary */
+               if (len - i > outsize - outpos) {
+                       outsize = outsize + ((len - i) - (outsize - outpos));
+                       outtmp = (char *) realloc(out, outsize);
+                       if (outtmp == NULL) {
+                               free(out);
+                               free(ucs);
+                               return NULL;
+                       }
+                       out = outtmp;
+               }
+
                /* s[i] is ascii */
                /* finish off everything up to char before next non-ascii */
                for ( i++; (i < len) && LDAP_UTF8_ISASCII(s + i); i++ ) {