plen = m.bv_len;
extra -= plen;
if (extra < 0) {
+ char *tmpnf;
while (extra < 0) {
extra += len;
len *= 2;
}
s -= (long)nf;
- nf = ch_realloc(nf, len + 1);
- if (nf == NULL) {
- free(nf);
+ tmpnf = ch_realloc(nf, len + 1);
+ if (tmpnf == NULL) {
+ ch_free(nf);
return(NULL);
}
+ nf = tmpnf;
s += (long)nf;
}
AC_MEMCPY(s, m.bv_val, plen);
int remap
)
{
- int i;
+ int i, j;
char **na;
struct berval mapped;
if (na == NULL)
return(NULL);
- for (i = 0; an[i].an_name.bv_val; ) {
+ for (i = j = 0; an[i].an_name.bv_val; i++) {
ldap_back_map(at_map, &an[i].an_name, &mapped, remap);
- if (mapped.bv_val != NULL) {
- na[i] = mapped.bv_val;
- i++;
- }
+ if (mapped.bv_val != NULL)
+ na[j++] = mapped.bv_val;
}
- na[i] = NULL;
+ if (j == 0 && i != 0)
+ na[j++] = LDAP_NO_ATTRS;
+ na[j] = NULL;
return(na);
}