From f8a727ec0cb85bec92e49397198d2028a84b8de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 3 Mar 2013 23:27:35 +0000 Subject: [PATCH] Always use openpam_straddch(3) to bootstrap the string, even if we have nothing to add to it. This simplifies the code and fixes a bug introduced in r553 where the first character in the string would always be set to '\0', instead of only when bootstrapping. git-svn-id: svn+ssh://svn.openpam.org/svn/openpam/trunk@636 185d5e19-27fe-0310-9dcf-9bff6b9f3609 --- lib/openpam_readword.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/lib/openpam_readword.c b/lib/openpam_readword.c index cd680df..5fba5bc 100644 --- a/lib/openpam_readword.c +++ b/lib/openpam_readword.c @@ -85,13 +85,8 @@ openpam_readword(FILE *f, int *lineno, size_t *lenp) /* begin quote */ quote = ch; /* edge case: empty quoted string */ - if (word == NULL && (word = malloc(1)) == NULL) { - openpam_log(PAM_LOG_ERROR, "malloc(): %m"); - errno = ENOMEM; + if (openpam_straddch(&word, &size, &len, 0) != 0) return (NULL); - } - *word = '\0'; - size = 1; } else if (ch == quote && !escape) { /* end quote */ quote = 0;