]> Devoid-pointer.net GitWeb - libHPCS.git/commitdiff
Fix null pointer checks in read_dad_wavelength()
authorMichal Malý <madcatxster@devoid-pointer.net>
Fri, 11 Jul 2014 08:40:07 +0000 (10:40 +0200)
committerMichal Malý <madcatxster@devoid-pointer.net>
Fri, 11 Jul 2014 08:40:07 +0000 (10:40 +0200)
libhpcs.c

index 3b8d9aa56779d63cdcaf634174202034e2e2bbe4..fe4ecd67dd2ac460a7b094f243d4faf1c51d12eb 100644 (file)
--- 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? */