*opt = malloc((pos - input) + 1);
*val = strdup(pos + 1);
if (!*opt || !*val) {
+ free(*opt);
+ *opt = NULL;
+ free(*val);
+ *val = NULL;
return ENOMEM;
}
memcpy(*opt, input, pos - input);
if (opt && !strcmp(opt, "dbname")) {
if (dbname) free(dbname);
dbname = strdup(val);
+ if (dbname == NULL) {
+ free(opt);
+ free(val);
+ return ENOMEM;
+ }
}
else if (!opt && !strcmp(val, "temporary") ) {
tempdb = 1;
krb5_db2_get_db_opt(*t_ptr, &opt, &val);
if (opt && !strcmp(opt, "dbname")) {
db_name = strdup(val);
+ if (db_name == NULL) {
+ free(opt);
+ free(val);
+ return ENOMEM;
+ }
}
else if (!opt && !strcmp(val, "temporary")) {
tempdb = 1;
}
db_name = strdup(value);
+ if (db_name == NULL) {
+ status = ENOMEM;
+ profile_release_string(value);
+ goto clean_n_exit;
+ }
status = krb5_db2_db_set_name(kcontext, value, tempdb);
profile_release_string(value);
if (!status) {
krb5_db2_get_db_opt(*t_ptr, &opt, &val);
if (opt && !strcmp(opt, "dbname")) {
db_name = strdup(val);
+ if (db_name == NULL) {
+ free(opt);
+ free(val);
+ return ENOMEM;
+ }
}
else if (!opt && !strcmp(val, "temporary")) {
tempdb = 1;
}
db_name = strdup(value);
+ if (db_name == NULL) {
+ status = ENOMEM;
+ goto clean_n_exit;
+ }
status = krb5_db2_db_set_name(kcontext, value, tempdb);
profile_release_string(value);
if (status) {
kdb5_dal_handle *dal_handle = kcontext->dal_handle;
krb5_db2_context *db_ctx = dal_handle->db_context;
db_name = strdup(db_ctx->db_name);
+ if (db_name == NULL) {
+ status = ENOMEM;
+ goto clean_n_exit;
+ }
}
assert(kcontext->dal_handle != NULL);