diff options
author | dae hyun, yang <daehyun.yang@gmail.com> | 2016-05-08 01:26:39 +0900 |
---|---|---|
committer | dae hyun, yang <daehyun.yang@gmail.com> | 2016-05-08 01:26:39 +0900 |
commit | 1476345476ad490ec71e88d53ecd4679f4163a38 (patch) | |
tree | b0ec60103d04503f88dde356848ee60c7fd02c25 /gnuradio-runtime | |
parent | 75b6e340f82e59d00badeba70263e755075b49c0 (diff) |
runtime: fixed dangling pointer returns in vmcircbuf_prefs.cc and fft.cc
The following error messages occurs In Windows XP/7/8
:Invalid argument
:Invalid argument
:Invalid argument
The reason is
return path.string().c_str(); // return invalid pointer in Windows
XP/7/8
Diffstat (limited to 'gnuradio-runtime')
-rw-r--r-- | gnuradio-runtime/lib/vmcircbuf_prefs.cc | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/gnuradio-runtime/lib/vmcircbuf_prefs.cc b/gnuradio-runtime/lib/vmcircbuf_prefs.cc index a786b8a881..4cb09f69f8 100644 --- a/gnuradio-runtime/lib/vmcircbuf_prefs.cc +++ b/gnuradio-runtime/lib/vmcircbuf_prefs.cc @@ -45,12 +45,13 @@ namespace gr { * The simplest thing that could possibly work: * the key is the filename; the value is the file contents. */ - static const char * + + static std::string pathname(const char *key) { static fs::path path; - path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key; - return path.string().c_str(); + path = fs::path(gr::appdata_path()) / ".gnuradio" / "prefs" / key; + return path.string(); } static void @@ -70,9 +71,9 @@ namespace gr { { gr::thread::scoped_lock guard(s_vm_mutex); - FILE *fp = fopen(pathname (key), "r"); + FILE *fp = fopen(pathname (key).c_str(), "r"); if(fp == 0) { - perror(pathname (key)); + perror(pathname (key).c_str()); return 0; } @@ -80,7 +81,7 @@ namespace gr { value[ret] = '\0'; if(ret == 0 && !feof(fp)) { if(ferror(fp) != 0) { - perror(pathname (key)); + perror(pathname (key).c_str()); fclose(fp); return -1; } @@ -96,16 +97,16 @@ namespace gr { ensure_dir_path(); - FILE *fp = fopen(pathname(key), "w"); + FILE *fp = fopen(pathname(key).c_str(), "w"); if(fp == 0) { - perror(pathname (key)); + perror(pathname (key).c_str()); return; } size_t ret = fwrite(value, 1, strlen(value), fp); if(ret == 0) { if(ferror(fp) != 0) { - perror(pathname (key)); + perror(pathname (key).c_str()); fclose(fp); return; } |