From 2c3ae266e3b9cbb670c07b61bb696e578ba2bfb0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michal=20Mal=C3=BD?= Date: Fri, 11 Jul 2014 10:40:07 +0200 Subject: [PATCH] Fix null pointer checks in read_dad_wavelength() --- libhpcs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libhpcs.c b/libhpcs.c index 3b8d9aa..fe4ecd6 100644 --- a/libhpcs.c +++ b/libhpcs.c @@ -238,11 +238,12 @@ static enum HPCS_ParseCode read_dad_wavelength(FILE* datafile, struct HPCS_Wavel return pret; /* Read MEASURED wavelength */ - start_idx = strstr(str, WAVELENGTH_MEASURED_TEXT) + strlen(WAVELENGTH_MEASURED_TEXT); + start_idx = strstr(str, WAVELENGTH_MEASURED_TEXT); if (start_idx == NULL) { ret = PARSE_W_NO_DATA; goto out; } + start_idx += strlen(WAVELENGTH_MEASURED_TEXT); interv_idx = strchr(start_idx, WAVELENGTH_DELIMITER_TEXT); if (interv_idx == NULL) { PR_DEBUG("No spectral interval value\n"); @@ -283,12 +284,13 @@ static enum HPCS_ParseCode read_dad_wavelength(FILE* datafile, struct HPCS_Wavel /* Read REFERENCE wavelength */ - start_idx = strstr(end_idx, WAVELENGTH_REFERENCE_TEXT) + strlen(WAVELENGTH_REFERENCE_TEXT); + start_idx = strstr(end_idx, WAVELENGTH_REFERENCE_TEXT); if (start_idx == NULL) { PR_DEBUG("No reference wavelength data\n"); ret = PARSE_W_NO_DATA; goto out2; } + start_idx += strlen(WAVELENGTH_REFERENCE_TEXT); interv_idx = strchr(start_idx, WAVELENGTH_DELIMITER_TEXT); if (interv_idx == NULL) { /* Is the reference wavelength disabled? */ -- 2.43.5