diff options
author | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-02-11 15:36:13 (GMT) |
---|---|---|
committer | Magnus Lundborg <lundborg.magnus@gmail.com> | 2014-02-11 15:36:13 (GMT) |
commit | cc47950e84ed4c0a3d0a32d98bb3da0080467278 (patch) | |
tree | 9e4d83e7d0f1b4d049a8165923c0a4339c6a9d7c /src | |
parent | 506198102980db786648af48bd572af7f7cc3ba4 (diff) |
Fixed some clang warnings.
Change-Id: I7463cab38975107cfff102434c525233ed996563
Diffstat (limited to 'src')
-rw-r--r-- | src/compression/tng_compress.c | 9 | ||||
-rw-r--r-- | src/lib/tng_io.c | 26 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/compression/tng_compress.c b/src/compression/tng_compress.c index 6174e8f..b39d722 100644 --- a/src/compression/tng_compress.c +++ b/src/compression/tng_compress.c @@ -423,9 +423,12 @@ static void compress_quantized_pos(int *quant, int *quant_inter, int *quant_intr if (data) bufferfix((unsigned char*)data+bufloc,(fix_t)length,4); bufloc+=4; - if (data) - memcpy(data+bufloc,datablock,length); - free(datablock); + if (datablock) + { + if (data) + memcpy(data+bufloc,datablock,length); + free(datablock); + } bufloc+=length; } *nitems=bufloc; diff --git a/src/lib/tng_io.c b/src/lib/tng_io.c index 33ca978..b51796a 100644 --- a/src/lib/tng_io.c +++ b/src/lib/tng_io.c @@ -5459,6 +5459,11 @@ static tng_function_status tng_allocate_data_mem int64_t i, j, size, frame_alloc; (void)tng_data; + if(n_values_per_frame == 0) + { + return(TNG_FAILURE); + } + if(data->strings && data->datatype == TNG_CHAR_DATA) { for(i = data->n_frames; i--;) @@ -9607,9 +9612,23 @@ tng_function_status DECLSPECDLLEXPORT tng_trajectory_init_from_src(tng_trajector frame_set = &dest->current_trajectory_frame_set; + dest->input_file_path = malloc(strlen(src->input_file_path) + 1); + if(!dest->input_file_path) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n", + (int)strlen(src->input_file_path) + 1, __FILE__, __LINE__); + return(TNG_CRITICAL); + } strcpy(dest->input_file_path, src->input_file_path); dest->input_file = 0; dest->input_file_len = src->input_file_len; + dest->output_file_path = malloc(strlen(src->output_file_path) + 1); + if(!dest->output_file_path) + { + fprintf(stderr, "TNG library: Cannot allocate memory (%d bytes). %s: %d\n", + (int)strlen(src->output_file_path) + 1, __FILE__, __LINE__); + return(TNG_CRITICAL); + } strcpy(dest->output_file_path, src->output_file_path); dest->output_file = 0; @@ -10644,7 +10663,12 @@ tng_function_status DECLSPECDLLEXPORT tng_implicit_num_particles_set stat = tng_molecule_find(tng_data, "TNG_IMPLICIT_MOL", -1, &mol); if(stat == TNG_SUCCESS) { - tng_molecule_cnt_get(tng_data, mol, &n_impl); + if(tng_molecule_cnt_get(tng_data, mol, &n_impl) != TNG_SUCCESS) + { + fprintf(stderr, "TNG library: Cannot get the number of implicit molecules. %s: %d\n", + __FILE__, __LINE__); + return(TNG_FAILURE); + } diff -= n_impl * mol->n_atoms; } |