From 902f9dd1fa8be9a6eb5f1f6010daf44dc5af56fe Mon Sep 17 00:00:00 2001 From: Richard Berger Date: Wed, 15 Dec 2021 15:05:59 -0500 Subject: [PATCH] Move allocation to correct location --- src/reader_native.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/reader_native.cpp b/src/reader_native.cpp index b029b2fe37..e577bd240f 100644 --- a/src/reader_native.cpp +++ b/src/reader_native.cpp @@ -212,7 +212,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, { bigint natoms = 0; int len = 0; - char *labelline; + char *labelline = nullptr; if (binary) { read_buf(&natoms, sizeof(bigint), 1); @@ -245,7 +245,6 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, // newer format includes units string, columns string // and time read_buf(&len, sizeof(int), 1); - labelline = new char[len + 1]; if (len > 0) { // has units @@ -263,6 +262,7 @@ bigint ReaderNative::read_header(double box[3][3], int &boxinfo, int &triclinic, } read_buf(&len, sizeof(int), 1); + labelline = new char[len + 1]; read_buf(labelline, sizeof(char), len); labelline[len] = '\0'; }