summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2011-10-21 15:12:04 +0200
committerFelix Fietkau <nbd@openwrt.org>2011-10-21 15:17:06 +0200
commitef95525edc1ade7e729187b011de889b8f5f57c6 (patch)
treeb43b88ba7bafa276ec0b554dd80ebd31ff832019 /file.c
parent2b86a11e49aa14d24c1e85ff5a7bd5ce58565df6 (diff)
downloaduci-ef95525edc1ade7e729187b011de889b8f5f57c6.tar.gz
check result of memory allocations (patch by Stanislav Fomichev)
Diffstat (limited to 'file.c')
-rw-r--r--file.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/file.c b/file.c
index d23e910..0530eb2 100644
--- a/file.c
+++ b/file.c
@@ -508,7 +508,7 @@ invalid:
/*
* escape an uci string for export
*/
-static char *uci_escape(struct uci_context *ctx, const char *str)
+static const char *uci_escape(struct uci_context *ctx, const char *str)
{
const char *end;
int ofs = 0;
@@ -516,6 +516,9 @@ static char *uci_escape(struct uci_context *ctx, const char *str)
if (!ctx->buf) {
ctx->bufsz = LINEBUF;
ctx->buf = malloc(LINEBUF);
+
+ if (!ctx->buf)
+ return str;
}
while (1) {