diff --git a/lib/commonio.c b/lib/commonio.c index aa6d8c87..1a6f1db5 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -648,11 +648,10 @@ int commonio_open (struct commonio_db *db, int mode) size_t len; buflen += BUFLEN; - cp = REALLOC(buf, buflen, char); - if (NULL == cp) { - goto cleanup_buf; + buf = REALLOCF(buf, buflen, char); + if (NULL == buf) { + goto cleanup_ENOMEM; } - buf = cp; len = strlen (buf); if (db->ops->fgets (buf + len, (int) (buflen - len), diff --git a/lib/subordinateio.c b/lib/subordinateio.c index a4e114de..9dd7702a 100644 --- a/lib/subordinateio.c +++ b/lib/subordinateio.c @@ -929,9 +929,8 @@ static bool all_digits(const char *str) static int append_uids(uid_t **uids, const char *owner, int n) { - uid_t owner_uid; - uid_t *ret; - int i; + int i; + uid_t owner_uid; if (all_digits(owner)) { i = sscanf(owner, "%d", &owner_uid); @@ -957,13 +956,11 @@ static int append_uids(uid_t **uids, const char *owner, int n) return n; } - ret = REALLOC(*uids, n + 1, uid_t); - if (!ret) { - free(*uids); + *uids = REALLOCF(*uids, n + 1, uid_t); + if (!*uids) return -1; - } - ret[n] = owner_uid; - *uids = ret; + + (*uids)[n] = owner_uid; return n+1; }