From 23a6af9398fbfa89c87f412ed139a76e44fa9d65 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 31 Jul 2019 10:36:38 +0200 Subject: copy_geom: Tidy up logic some more --- libcrystfel/src/detector.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libcrystfel/src/detector.c b/libcrystfel/src/detector.c index ac33bbc0..5055139f 100644 --- a/libcrystfel/src/detector.c +++ b/libcrystfel/src/detector.c @@ -1798,10 +1798,10 @@ struct detector *copy_geom(const struct detector *in) if ( in == NULL ) return NULL; out = malloc(sizeof(struct detector)); - memcpy(out, in, sizeof(struct detector)); + if ( out == NULL ) return NULL; - /* Copy all fields */ - *out = *in; + /* Copy everything */ + memcpy(out, in, sizeof(struct detector)); out->panels = malloc(out->n_panels * sizeof(struct panel)); memcpy(out->panels, in->panels, out->n_panels * sizeof(struct panel)); -- cgit v1.2.3