Author: jelmer Date: 2005-08-31 14:26:20 +0000 (Wed, 31 Aug 2005) New Revision: 9826
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9826 Log: Add some more OOM checks Modified: branches/SAMBA_4_0/source/param/generic.c branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c Changeset: Modified: branches/SAMBA_4_0/source/param/generic.c =================================================================== --- branches/SAMBA_4_0/source/param/generic.c 2005-08-31 14:25:18 UTC (rev 9825) +++ branches/SAMBA_4_0/source/param/generic.c 2005-08-31 14:26:20 UTC (rev 9826) @@ -68,6 +68,9 @@ if (section == NULL) { section = talloc_zero(ctx, struct param_section); + if (section == NULL) + return NULL; + section->name = talloc_strdup(section, section_name); DLIST_ADD(ctx->sections, section); } @@ -75,6 +78,9 @@ p = param_section_get(section, name); if (p == NULL) { p = talloc_zero(section, struct param); + if (p == NULL) + return NULL; + p->name = talloc_strdup(p, name); DLIST_ADD(section->parameters, p); } @@ -146,6 +152,9 @@ { struct param *p = param_get_add(ctx, section, param); + if (!p) + return; + p->value = talloc_asprintf(p, "%d", value); } @@ -163,6 +172,9 @@ { struct param *p = param_get_add(ctx, section, name); + if (!p) + return; + p->value = talloc_asprintf(p, "%lu", value); } @@ -173,6 +185,9 @@ if (section == NULL) { section = talloc_zero(ctx, struct param_section); + if (section == NULL) + return False; + section->name = talloc_strdup(section, name); DLIST_ADD(ctx->sections, section); @@ -191,6 +206,9 @@ if (!p) { p = talloc_zero(ctx->sections, struct param); + if (p == NULL) + return False; + p->name = talloc_strdup(p, name); p->value = talloc_strdup(p, value); DLIST_ADD(ctx->sections->parameters, p); @@ -211,8 +229,10 @@ int param_read(struct param_context *ctx, const char *fn) { ctx->sections = talloc_zero(ctx, struct param_section); + if (ctx->sections == NULL) + return -1; + ctx->sections->name = talloc_strdup(ctx->sections, "global"); - if (!pm_process( fn, param_sfunc, param_pfunc, ctx)) { return -1; } Modified: branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c =================================================================== --- branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c 2005-08-31 14:25:18 UTC (rev 9825) +++ branches/SAMBA_4_0/source/scripting/ejs/smbcalls_param.c 2005-08-31 14:26:20 UTC (rev 9826) @@ -70,7 +70,7 @@ const char **ret; if (argc != 1 && argc != 2) { - ejsSetErrorMsg(eid, "param.get invalid argument count"); + ejsSetErrorMsg(eid, "param.get_list invalid argument count"); return -1; } @@ -83,7 +83,7 @@ ret = param_get_string_list(ctx, NULL, argv[0], NULL); } - if (ret) { + if (ret != NULL) { mpr_Return(eid, mprList("array", ret)); } else { mpr_Return(eid, mprCreateUndefinedVar());
