diff options
| author | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-26 17:18:56 -0400 |
|---|---|---|
| committer | Nalin Dahyabhai <nalin.dahyabhai@pobox.com> | 2008-06-26 17:18:56 -0400 |
| commit | 8bdafe29900349b315bf37da112e1a3f6f680d34 (patch) | |
| tree | 1c1f7b533f78f3c0c607060520f8d7303c5512a1 /src | |
| parent | b729ea4733d63a7601c71f012d67bb73e3a10d55 (diff) | |
| download | slapi-nis-8bdafe29900349b315bf37da112e1a3f6f680d34.tar.gz slapi-nis-8bdafe29900349b315bf37da112e1a3f6f680d34.tar.xz slapi-nis-8bdafe29900349b315bf37da112e1a3f6f680d34.zip | |
- minor cleanups
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend.c b/src/backend.c index f57707b..436dad4 100644 --- a/src/backend.c +++ b/src/backend.c @@ -150,17 +150,18 @@ backend_dup_strlist_n(char **strlist, int n) } /* Allocate space for the array of pointers (with NULL terminator) and * then the string data. */ - ret = malloc(((i + 1) * sizeof(char *)) + l); + ret = malloc(((n + 1) * sizeof(char *)) + l); if (ret != NULL) { /* Figure out where the string data will start. */ - s = (char *) &ret[i + 1]; + s = (char *) ret; + s += ((n + 1) * sizeof(char *)); for (i = 0; i < n; i++) { /* Set the address of this string, copy the data * around, and then prepare the address of the next * string. */ ret[i] = s; strcpy(s, strlist[i]); - s += (strlen(s) + 1); + s += (strlen(strlist[i]) + 1); } /* NULL-terminate the array. */ ret[i] = NULL; |
