From 53109e6d92a4414a3c30253da02b99da928b6a03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Sun, 10 Mar 2019 12:43:35 +0000 Subject: [PATCH] Fix realloc pointer shifts Former-commit-id: 93631e50597ccde2f179fcd55e9b14c5bf85d3e9 --- qpms/scatsystem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index 70a466c..27a1ad2 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -611,13 +611,17 @@ qpms_scatsys_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, const qp char *old_otspace = ss->otspace; ss->otspace = realloc(ss->otspace, otspace_sz); ptrdiff_t shift = ss->otspace - old_otspace; - if(shift) + if(shift) { for (size_t oi = 0; oi < ss->orbit_type_count; ++oi) { ss->orbit_types[oi].action = (void *)(((char *) (ss->orbit_types[oi].action)) + shift); ss->orbit_types[oi].tmatrices = (void *)(((char *) (ss->orbit_types[oi].tmatrices)) + shift); ss->orbit_types[oi].irbase_sizes = (void *)(((char *) (ss->orbit_types[oi].irbase_sizes)) + shift); + ss->orbit_types[oi].irbase_cumsizes = (void *)(((char *) (ss->orbit_types[oi].irbase_cumsizes)) + shift); + ss->orbit_types[oi].irbase_offsets = (void *)(((char *) (ss->orbit_types[oi].irbase_offsets)) + shift); ss->orbit_types[oi].irbases = (void *)(((char *) (ss->orbit_types[oi].irbases)) + shift); } + ss->otspace_end += shift; + } } // Set ss->fecv_size and ss->fecv_pstarts