This is the mail archive of the
cygwin-apps-cvs
mailing list for the cygwin-apps project.
[setup - the official Cygwin setup program used to install Cygwin and keep it up to date] branch master, updated. release_2.874-25-gf882d56
- From: corinna at sourceware dot org
- To: cygwin-apps-cvs at sourceware dot org
- Date: 1 Sep 2016 12:46:25 -0000
- 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
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