public inbox for cygwin-apps-cvs@sourceware.org help / color / mirror / Atom feed
From: corinna@sourceware.org To: cygwin-apps-cvs@sourceware.org Subject: [setup - the official Cygwin setup program used to install Cygwin and keep it up to date] branch master, updated. release_2.874-25-gf882d56 Date: Thu, 01 Sep 2016 12:46:00 -0000 [thread overview] Message-ID: <20160901124625.114536.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/setup.git;h=f882d56e593fe2338e4eb7c444719c4e8697fd87 commit f882d56e593fe2338e4eb7c444719c4e8697fd87 Author: Corinna Vinschen <corinna@vinschen.de> Date: Thu Sep 1 14:46:21 2016 +0200 Fix invalid deleting of a local pointer in UserSettings::UserSettings Convert buf to a unique_ptr instead. Signed-off-by: Corinna Vinschen <corinna@vinschen.de> Diff: --- UserSettings.cc | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/UserSettings.cc b/UserSettings.cc index dd50c52..f4917ec 100644 --- a/UserSettings.cc +++ b/UserSettings.cc @@ -13,6 +13,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <memory> #include "UserSettings.h" #include "io_stream.h" #include "win32.h" @@ -92,15 +93,15 @@ UserSettings::UserSettings (std::string local_dir) return; size_t sz = f->get_size (); - char *buf = new char [sz + 2]; - ssize_t szread = f->read (buf, sz); + std::unique_ptr<char[]> buf (new char [sz + 2]); + ssize_t szread = f->read (buf.get (), sz); delete f; if (szread > 0) { buf[szread] = '\0'; buf[szread + 1] = '\0'; - for (char *p = strtok (buf, "\n"); p; p = strtok (p, "\n")) + for (char *p = strtok (buf.get (), "\n"); p; p = strtok (p, "\n")) { char *eol = strchr (p, '\0'); char *thiskey = trim (p); @@ -131,7 +132,6 @@ UserSettings::UserSettings (std::string local_dir) set (thiskey, thisval); } } - delete buf; } unsigned int
reply other threads:[~2016-09-01 12:46 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=20160901124625.114536.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=cygwin-apps-cvs@sourceware.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: linkBe 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).