List for cgit developers and users
 help / color / mirror / Atom feed
From: cgit at cryptocrack.de (Lukas Fleischer)
Subject: [PATCH 2/3] Maŕk cgit_environment members const
Date: Mon,  1 Apr 2013 17:11:14 +0200	[thread overview]
Message-ID: <1364829075-18159-2-git-send-email-cgit@cryptocrack.de> (raw)
In-Reply-To: <1364829075-18159-1-git-send-email-cgit@cryptocrack.de>

These reflect the values of environment variables and should never be
changed. Add another xstrdup() when we assign environment variables to
strings that are potentially non-constant.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
 cgit.c |  4 ++--
 cgit.h | 20 ++++++++++----------
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/cgit.c b/cgit.c
index afafcce..d145f8a 100644
--- a/cgit.c
+++ b/cgit.c
@@ -401,9 +401,9 @@ static void prepare_context(struct cgit_context *ctx)
 	ctx->page.etag = NULL;
 	memset(&ctx->cfg.mimetypes, 0, sizeof(struct string_list));
 	if (ctx->env.script_name)
-		ctx->cfg.script_name = ctx->env.script_name;
+		ctx->cfg.script_name = xstrdup(ctx->env.script_name);
 	if (ctx->env.query_string)
-		ctx->qry.raw = ctx->env.query_string;
+		ctx->qry.raw = xstrdup(ctx->env.query_string);
 	if (!ctx->env.cgit_config)
 		ctx->env.cgit_config = CGIT_CONFIG;
 }
diff --git a/cgit.h b/cgit.h
index ed5cf14..081f669 100644
--- a/cgit.h
+++ b/cgit.h
@@ -255,16 +255,16 @@ struct cgit_page {
 };
 
 struct cgit_environment {
-	char *cgit_config;
-	char *http_host;
-	char *https;
-	char *no_http;
-	char *path_info;
-	char *query_string;
-	char *request_method;
-	char *script_name;
-	char *server_name;
-	char *server_port;
+	const char *cgit_config;
+	const char *http_host;
+	const char *https;
+	const char *no_http;
+	const char *path_info;
+	const char *query_string;
+	const char *request_method;
+	const char *script_name;
+	const char *server_name;
+	const char *server_port;
 };
 
 struct cgit_context {
-- 
1.8.2.411.g65a544e





  reply	other threads:[~2013-04-01 15:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-01 15:11 [PATCH 1/3] Return const char * in cgit_{httpscheme, hosturl, rooturl}() cgit
2013-04-01 15:11 ` cgit [this message]
2013-04-04 14:17   ` [PATCH 2/3] Maŕk cgit_environment members const Jason
2013-04-01 15:11 ` [PATCH 3/3] Do not unnecessarily strdup() environment variables cgit
2013-04-04 14:19   ` Jason
2013-04-01 15:35 ` [PATCH 1/3] Return const char * in cgit_{httpscheme, hosturl, rooturl}() john
2013-04-01 17:53   ` john
2013-04-01 19:51   ` cgit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1364829075-18159-2-git-send-email-cgit@cryptocrack.de \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).