From: Jim Meyering <jim@meyering.net>
To: Project Hail <hail-devel@vger.kernel.org>
Subject: [PATCH tabled] server/status.c: don't deref NULL on failed strdup
Date: Thu, 23 Sep 2010 11:13:14 +0200 [thread overview]
Message-ID: <87bp7oyg9h.fsf@meyering.net> (raw)
From aed01fa24688257fdf6f3c5ecf6983f61b8749f8 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@redhat.com>
Date: Thu, 23 Sep 2010 11:12:27 +0200
Subject: [PATCH tabled] server/status.c: don't deref NULL on failed strdup
Use a non-malloc'd string upon failed strdup so
we don't have to diagnose failure.
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
server/status.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/server/status.c b/server/status.c
index e9fbb38..7d4cc9a 100644
--- a/server/status.c
+++ b/server/status.c
@@ -1,6 +1,6 @@
/*
- * Copyright 2008-2009 Red Hat, Inc.
+ * Copyright 2008-2010 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -158,13 +158,14 @@ bool stat_evt_http_req(struct client *cli, unsigned int events)
char *path = NULL;
// int rc;
bool rcb;
+ char *root = (char *) "/";
/* grab useful headers */
// content_len_str = hreq_hdr(req, "content-length");
path = strdup(req->uri.path);
if (!path)
- path = strdup("/");
+ path = root;
if (debugging)
applog(LOG_INFO, "%s: status method %s, path '%s'",
@@ -195,6 +196,7 @@ bool stat_evt_http_req(struct client *cli, unsigned int events)
rcb = stat_err(cli, InvalidArgument);
}
- free(path);
+ if (path != root);
+ free(path);
return rcb;
}
--
1.7.3.234.g7bba3
reply other threads:[~2010-09-23 9:13 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87bp7oyg9h.fsf@meyering.net \
--to=jim@meyering.net \
--cc=hail-devel@vger.kernel.org \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).