aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-07-28 15:31:22 +0200
committerThomas White <taw@physics.org>2020-07-29 18:53:45 +0200
commit66b9a483757ed3251b93272d126b0c39d8b28454 (patch)
treeb2b53689793f922b7899c121c22a09eef390ce94 /libcrystfel
parent694e24e6e87f7891afc8138b0067ddae95e9866d (diff)
Fix a couple of memory bugs in event expansion
Diffstat (limited to 'libcrystfel')
-rw-r--r--libcrystfel/src/image-hdf5.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libcrystfel/src/image-hdf5.c b/libcrystfel/src/image-hdf5.c
index 6c2a323a..fac79e99 100644
--- a/libcrystfel/src/image-hdf5.c
+++ b/libcrystfel/src/image-hdf5.c
@@ -269,7 +269,6 @@ char *substitute_path(const char *ev, const char *pattern)
free(plvals);
return NULL;
}
- subs[0] = '\0';
pl_pos = strchr(pattern, '%');
if ( pl_pos == NULL ) {
@@ -278,6 +277,7 @@ char *substitute_path(const char *ev, const char *pattern)
return NULL;
}
strncpy(subs, pattern, pl_pos-pattern);
+ subs[pl_pos-pattern] = '\0';
start = pl_pos+1;
for ( i=0; i<n_plvals; i++ ) {
@@ -1408,7 +1408,9 @@ char **expand_paths(hid_t fh, char *pattern, int *n_evs)
start = pattern+1;
for ( i=0; i<n_sep; i++ ) {
char *sep = strchr(start, '/');
- assert(sep != NULL);
+ if ( sep == NULL ) {
+ sep = start+strlen(start);
+ }
pattern_bits[i] = strndup(start, sep-start);
if ( pattern_bits[i] == NULL ) return NULL;
start = sep+1;