X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=cgiedit.c;h=4579b35b8cd2b2cd4c141e8325af3d4faecf9456;hp=3b40ee3ffdf94bdb8a07064df388079f621c3014;hb=6c92f003d85e32dfcfed47d26263e9db40806d46;hpb=979828a722c6f1434897a37155a6938b4843171a diff --git a/cgiedit.c b/cgiedit.c index 3b40ee3f..4579b35b 100644 --- a/cgiedit.c +++ b/cgiedit.c @@ -1,4 +1,4 @@ -const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.84 2014/10/18 11:29:06 fabiankeil Exp $"; +const char cgiedit_rcs[] = "$Id: cgiedit.c,v 1.88 2016/02/26 12:29:38 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/cgiedit.c,v $ @@ -843,11 +843,7 @@ jb_err edit_write_file(struct editable_file * file) freez(file->version_str); snprintf(version_buf, sizeof(version_buf), "%u", file->version); version_buf[sizeof(version_buf)-1] = '\0'; - file->version_str = strdup(version_buf); - if (version_buf == NULL) - { - return JB_ERR_MEMORY; - } + file->version_str = strdup_or_die(version_buf); return JB_ERR_OK; } @@ -1223,14 +1219,7 @@ jb_err edit_parse_actions_file(struct editable_file * file) return JB_ERR_PARSE; } - if ((new_alias = zalloc(sizeof(*new_alias))) == NULL) - { - /* Out of memory */ - free(name); - free(value); - free_alias_list(alias_list); - return JB_ERR_MEMORY; - } + new_alias = zalloc_or_die(sizeof(*new_alias)); err = get_actions(value, alias_list, new_alias->action); if (err) @@ -1398,11 +1387,7 @@ jb_err edit_read_file_lines(FILE *fp, struct file_line ** pfile, int *newline) *pfile = NULL; - cur_line = first_line = zalloc(sizeof(struct file_line)); - if (cur_line == NULL) - { - return JB_ERR_MEMORY; - } + cur_line = first_line = zalloc_or_die(sizeof(struct file_line)); cur_line->type = FILE_LINE_UNPROCESSED; @@ -1418,13 +1403,7 @@ jb_err edit_read_file_lines(FILE *fp, struct file_line ** pfile, int *newline) do { prev_line = cur_line; - cur_line = prev_line->next = zalloc(sizeof(struct file_line)); - if (cur_line == NULL) - { - /* Out of memory */ - edit_free_file_lines(first_line); - return JB_ERR_MEMORY; - } + cur_line = prev_line->next = zalloc_or_die(sizeof(struct file_line)); cur_line->type = FILE_LINE_UNPROCESSED; @@ -1554,12 +1533,7 @@ jb_err edit_read_file(struct client_state *csp, return err; } - file = (struct editable_file *) zalloc(sizeof(*file)); - if (file == NULL) - { - edit_free_file_lines(lines); - return err; - } + file = zalloc_or_die(sizeof(*file)); file->lines = lines; file->newline = newline; @@ -2346,7 +2320,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, { if (!strncmp(b->url->spec, "standard.", 9) && *(b->url->spec + 9) != '\0') { - if (err || (NULL == (section_exports = new_map()))) + if (err) { freez(buttons); free(section_template); @@ -2355,6 +2329,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, return JB_ERR_MEMORY; } + section_exports = new_map(); err = map(section_exports, "button-name", 1, b->url->spec + 9, 1); if (err || (NULL == (s = strdup(section_template)))) @@ -2486,15 +2461,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, while ((cur_line != NULL) && (cur_line->type == FILE_LINE_ACTION)) { - if (NULL == (section_exports = new_map())) - { - free(sections); - free(section_template); - free(url_template); - edit_free_file(file); - free_map(exports); - return JB_ERR_MEMORY; - } + section_exports = new_map(); snprintf(buf, sizeof(buf), "%u", line_number); err = map(section_exports, "s", 1, buf, 1); @@ -2558,17 +2525,7 @@ jb_err cgi_edit_actions_list(struct client_state *csp, while ((cur_line != NULL) && (cur_line->type == FILE_LINE_URL)) { - if (NULL == (url_exports = new_map())) - { - free(urls); - free(sections); - free(section_template); - free(url_template); - edit_free_file(file); - free_map(exports); - free_map(section_exports); - return JB_ERR_MEMORY; - } + url_exports = new_map(); snprintf(buf, sizeof(buf), "%u", line_number); err = map(url_exports, "p", 1, buf, 1); @@ -3456,13 +3413,7 @@ jb_err cgi_edit_actions_add_url(struct client_state *csp, /* At this point, the section header is in cur_line - add after this. */ /* Allocate the new line */ - new_line = (struct file_line *)zalloc(sizeof(*new_line)); - if (new_line == NULL) - { - free(new_pattern); - edit_free_file(file); - return JB_ERR_MEMORY; - } + new_line = zalloc_or_die(sizeof(*new_line)); /* Fill in the data members of the new line */ new_line->raw = NULL; @@ -3849,13 +3800,7 @@ jb_err cgi_edit_actions_section_add(struct client_state *csp, } /* Allocate the new line */ - new_line = (struct file_line *)zalloc(sizeof(*new_line)); - if (new_line == NULL) - { - free(new_text); - edit_free_file(file); - return JB_ERR_MEMORY; - } + new_line = zalloc_or_die(sizeof(*new_line)); /* Fill in the data members of the new line */ new_line->raw = NULL; @@ -4462,6 +4407,8 @@ jb_err cgi_toggle(struct client_state *csp, global_toggle_state = !global_toggle_state; } + log_error(LOG_LEVEL_INFO, "Now toggled %s.", global_toggle_state ? "ON" : "OFF"); + if (NULL == (exports = default_exports(csp, "toggle"))) { return JB_ERR_MEMORY;