summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/file.c16
-rw-r--r--main/utils.c3
-rw-r--r--main/xmldoc.c36
3 files changed, 37 insertions, 18 deletions
diff --git a/main/file.c b/main/file.c
index 4c25b987a..8ff88e7da 100644
--- a/main/file.c
+++ b/main/file.c
@@ -261,14 +261,12 @@ static char *build_filename(const char *filename, const char *ext)
ext = "WAV";
if (filename[0] == '/') {
- if (asprintf(&fn, "%s.%s", filename, ext) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
+ if (ast_asprintf(&fn, "%s.%s", filename, ext) < 0) {
fn = NULL;
}
} else {
- if (asprintf(&fn, "%s/sounds/%s.%s",
+ if (ast_asprintf(&fn, "%s/sounds/%s.%s",
ast_config_AST_DATA_DIR, filename, ext) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
fn = NULL;
}
}
@@ -1070,6 +1068,9 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons
format_found = 1;
fn = build_filename(filename, type);
+ if (!fn) {
+ continue;
+ }
errno = 0;
bfile = fopen(fn, "r");
@@ -1090,6 +1091,7 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons
fs->mode = mode;
fs->filename = ast_strdup(filename);
fs->vfs = NULL;
+ ast_free(fn);
break;
}
@@ -1137,6 +1139,9 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
format_found = 1;
fn = build_filename(filename, type);
+ if (!fn) {
+ continue;
+ }
fd = open(fn, flags | myflags, mode);
if (fd > -1) {
/* fdopen() the resulting file stream */
@@ -1198,6 +1203,9 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
ast_closestream(fs);
fs = NULL;
}
+ if (!buf) {
+ ast_free(fn);
+ }
continue;
}
fs->trans = NULL;
diff --git a/main/utils.c b/main/utils.c
index 8997305cb..3f21eb341 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -1070,9 +1070,8 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st
a->start_routine = start_routine;
a->data = data;
start_routine = dummy_start;
- if (asprintf(&a->name, "%-20s started at [%5d] %s %s()",
+ if (ast_asprintf(&a->name, "%-20s started at [%5d] %s %s()",
start_fn, line, file, caller) < 0) {
- ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno));
a->name = NULL;
}
data = a;
diff --git a/main/xmldoc.c b/main/xmldoc.c
index bb5afe056..0dc56c4b3 100644
--- a/main/xmldoc.c
+++ b/main/xmldoc.c
@@ -695,7 +695,9 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
if (!rootnode || !ast_xml_node_get_children(rootnode)) {
/* If the rootnode field is not found, at least print name. */
- ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : ""));
+ if (ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")) < 0) {
+ syntax = NULL;
+ }
return syntax;
}
@@ -735,7 +737,9 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
if (!hasparams) {
/* This application, function, option, etc, doesn't have any params. */
- ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : ""));
+ if (ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")) < 0) {
+ syntax = NULL;
+ }
return syntax;
}
@@ -807,13 +811,19 @@ static char *xmldoc_get_syntax_fun(struct ast_xml_node *rootnode, const char *ro
ast_free(syntax);
}
/* to give up is ok? */
- ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : ""));
+ if (ast_asprintf(&syntax, "%s%s", (printrootname ? rootname : ""), (printparenthesis ? "()" : "")) < 0) {
+ syntax = NULL;
+ }
return syntax;
}
paramname = ast_strdup(paramnameattr);
ast_xml_free_attr(paramnameattr);
}
+ if (!paramname) {
+ return NULL;
+ }
+
/* Defaults to 'false'. */
multiple = 0;
if ((multipletype = ast_xml_get_attribute(node, "multiple"))) {
@@ -1504,8 +1514,7 @@ static int xmldoc_parse_variablelist(struct ast_xml_node *node, const char *tabs
}
/* use this spacing (add 4 spaces) inside a variablelist node. */
- ast_asprintf(&vartabs, "%s ", tabs);
- if (!vartabs) {
+ if (ast_asprintf(&vartabs, "%s ", tabs) < 0) {
return ret;
}
for (tmp = ast_xml_node_get_children(node); tmp; tmp = ast_xml_node_get_next(tmp)) {
@@ -1641,7 +1650,9 @@ static int xmldoc_parse_enum(struct ast_xml_node *fixnode, const char *tabs, str
int ret = 0;
char *optiontabs;
- ast_asprintf(&optiontabs, "%s ", tabs);
+ if (ast_asprintf(&optiontabs, "%s ", tabs) < 0) {
+ return ret;
+ }
for (node = ast_xml_node_get_children(node); node; node = ast_xml_node_get_next(node)) {
if (xmldoc_parse_common_elements(node, (ret ? tabs : " - "), "\n", buffer)) {
@@ -1705,8 +1716,7 @@ static int xmldoc_parse_option(struct ast_xml_node *fixnode, const char *tabs, s
int ret = 0;
char *optiontabs;
- ast_asprintf(&optiontabs, "%s ", tabs);
- if (!optiontabs) {
+ if (ast_asprintf(&optiontabs, "%s ", tabs) < 0) {
return ret;
}
for (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) {
@@ -1810,8 +1820,8 @@ static void xmldoc_parse_parameter(struct ast_xml_node *fixnode, const char *tab
return;
}
- ast_asprintf(&internaltabs, "%s ", tabs);
- if (!internaltabs) {
+ if (ast_asprintf(&internaltabs, "%s ", tabs) < 0) {
+ ast_xml_free_attr(paramname);
return;
}
@@ -2378,8 +2388,10 @@ int ast_xmldoc_load_documentation(void)
globret = xml_pathmatch(xmlpattern, xmlpattern_maxlen, &globbuf);
#else
/* Get every *-LANG.xml file inside $(ASTDATADIR)/documentation */
- ast_asprintf(&xmlpattern, "%s/documentation{/thirdparty/,/}*-{%s,%.2s_??,%s}.xml", ast_config_AST_DATA_DIR,
- documentation_language, documentation_language, default_documentation_language);
+ if (ast_asprintf(&xmlpattern, "%s/documentation{/thirdparty/,/}*-{%s,%.2s_??,%s}.xml", ast_config_AST_DATA_DIR,
+ documentation_language, documentation_language, default_documentation_language) < 0) {
+ return 1;
+ }
globret = glob(xmlpattern, MY_GLOB_FLAGS, NULL, &globbuf);
#endif