aboutsummaryrefslogtreecommitdiff
path: root/c
diff options
context:
space:
mode:
authorJohn Ankarström <john@ankarstrom.se>2022-08-25 03:23:56 +0200
committerJohn Ankarström <john@ankarstrom.se>2022-08-25 03:23:56 +0200
commit69fc595053d2075d6a7d99d94912156851a0221d (patch)
tree438e6763e478f3f65d65d94e780b53e29debd674 /c
parent87f8d4ade699911717c4c9454a495b2eb630b4c6 (diff)
downloadEpisodeBrowser-69fc595053d2075d6a7d99d94912156851a0221d.tar.gz
Fix FileView::Initialized bug.
The bug doesn't appear with MinGW GCC, but when compiled with Visual Studio, the prorgam would perform a read access violation.
Diffstat (limited to 'c')
-rw-r--r--c/data.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/c/data.h b/c/data.h
index 1216359..7114440 100644
--- a/c/data.h
+++ b/c/data.h
@@ -84,20 +84,21 @@ struct FileView
static FileView Initialized(const wchar_t* filename, size_t c, size_t cInit = 0)
{
- bool bExisting = GetFileAttributes(filename) != INVALID_FILE_ATTRIBUTES;
- FileView fv(filename, c);
-
/* If file didn't exist, initialize it with defaults. */
- if (!bExisting) {
+ if (cInit && GetFileAttributes(filename) == INVALID_FILE_ATTRIBUTES) {
+ FileView fv(filename, c);
T t;
cInit = cInit? cInit: c;
for (size_t i = 0; i < cInit; i++)
memcpy(fv+i, &t, sizeof(T));
}
- return fv;
+ return { filename, c };
}
+ FileView(FileView<T>&) = delete;
+ FileView(FileView<T>&& fv) = delete;
+
FileView(const wchar_t* filename, size_t c) : c(c)
{
hf = CreateFile(filename, GENERIC_READ|GENERIC_WRITE,