catch error from as.*printf

This commit is contained in:
Love Hornquist Astrand
2010-05-30 14:12:39 -07:00
parent 2b1645aa08
commit 0b2b9d9834
4 changed files with 13 additions and 13 deletions

View File

@@ -247,7 +247,7 @@ krb5_get_error_message(krb5_context context, krb5_error_code code)
return strdup(msg);
}
if (asprintf(&str, "<unknown error: %d>", (int)code) == -1)
if (asprintf(&str, "<unknown error: %d>", (int)code) == -1 || str == NULL)
return NULL;
return str;

View File

@@ -298,10 +298,10 @@ _expand_temp_folder(krb5_context context, PTYPE param, const char *postfix, char
}
static int
_expand_userid(krb5_context context, PTYPE param, const char *postfix, char **ret)
_expand_userid(krb5_context context, PTYPE param, const char *postfix, char **str)
{
asprintf(ret, "%ld", (unsigned long)getuid());
if (*ret == NULL)
int ret = asprintf(str, "%ld", (unsigned long)getuid());
if (ret < 0 || *str == NULL)
return ENOMEM;
return 0;
}

View File

@@ -307,7 +307,7 @@ _krb5_erase_file(krb5_context context, const char *filename)
static krb5_error_code
fcc_gen_new(krb5_context context, krb5_ccache *id)
{
char *file, *exp_file = NULL;
char *file = NULL, *exp_file = NULL;
krb5_error_code ret;
krb5_fcache *f;
int fd;
@@ -318,8 +318,8 @@ fcc_gen_new(krb5_context context, krb5_ccache *id)
N_("malloc: out of memory", ""));
return KRB5_CC_NOMEM;
}
asprintf (&file, "%sXXXXXX", KRB5_DEFAULT_CCFILE_ROOT);
if(file == NULL) {
ret = asprintf (&file, "%sXXXXXX", KRB5_DEFAULT_CCFILE_ROOT);
if(ret < 0 || file == NULL) {
free(f);
krb5_set_error_message(context, KRB5_CC_NOMEM,
N_("malloc: out of memory", ""));
@@ -764,7 +764,7 @@ fcc_remove_cred(krb5_context context,
{
krb5_error_code ret;
krb5_ccache copy, newfile;
char *newname;
char *newname = NULL;
int fd;
ret = krb5_cc_new_unique(context, krb5_cc_type_memory, NULL, &copy);
@@ -783,10 +783,10 @@ fcc_remove_cred(krb5_context context,
return ret;
}
asprintf(&newname, "FILE:%s.XXXXXX", FILENAME(id));
if (newname == NULL) {
ret = asprintf(&newname, "FILE:%s.XXXXXX", FILENAME(id));
if (ret < 0 || newname == NULL) {
krb5_cc_destroy(context, copy);
return ret;
return ENOMEM;
}
fd = mkstemp(&newname[5]);

View File

@@ -428,8 +428,8 @@ krb5_vlog_msg(krb5_context context,
krb5_format_time(context, t, buf, sizeof(buf), TRUE);
}
if(actual == NULL) {
vasprintf(&msg, fmt, ap);
if(msg == NULL)
int ret = vasprintf(&msg, fmt, ap);
if(ret < 0 || msg == NULL)
actual = fmt;
else
actual = msg;