fix memleaks in pnm backend

- fix memleaks reported in bug #313553
merge-requests/1/head
Stéphane Voltz 2015-08-08 21:31:05 +02:00
rodzic dcce33376f
commit 1f1385ea67
1 zmienionych plików z 10 dodań i 7 usunięć

Wyświetl plik

@ -1120,7 +1120,10 @@ read_option (SANE_String line, SANE_String option_string,
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
if (strcmp (word, option_string) != 0) if (strcmp (word, option_string) != 0)
{
free(word);
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
}
free (word); free (word);
word = 0; word = 0;
@ -1240,7 +1243,6 @@ read_option (SANE_String line, SANE_String option_string,
if (word) if (word)
free (word); free (word);
word = 0;
return SANE_STATUS_GOOD; return SANE_STATUS_GOOD;
} }
@ -1453,7 +1455,7 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
{ {
FILE *fp; FILE *fp;
SANE_Int linenumber; SANE_Int linenumber;
SANE_Char line[PATH_MAX], *word; SANE_Char line[PATH_MAX], *word = NULL;
SANE_String_Const cp; SANE_String_Const cp;
SANE_Device *sane_device; SANE_Device *sane_device;
Test_Device *test_device, *previous_device; Test_Device *test_device, *previous_device;
@ -1481,7 +1483,9 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
DBG (4, "sane_init: reading config file `%s'\n", TEST_CONFIG_FILE); DBG (4, "sane_init: reading config file `%s'\n", TEST_CONFIG_FILE);
while (sanei_config_read (line, sizeof (line), fp)) while (sanei_config_read (line, sizeof (line), fp))
{ {
word = 0; if (word)
free (word);
word = NULL;
linenumber++; linenumber++;
cp = sanei_config_get_string (line, &word); cp = sanei_config_get_string (line, &word);
@ -1490,8 +1494,6 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
DBG (5, DBG (5,
"sane_init: config file line %3d: ignoring empty line\n", "sane_init: config file line %3d: ignoring empty line\n",
linenumber); linenumber);
if (word)
free (word);
continue; continue;
} }
if (word[0] == '#') if (word[0] == '#')
@ -1499,7 +1501,6 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
DBG (5, DBG (5,
"sane_init: config file line %3d: ignoring comment line\n", "sane_init: config file line %3d: ignoring comment line\n",
linenumber); linenumber);
free (word);
continue; continue;
} }
@ -1599,6 +1600,8 @@ sane_init (SANE_Int * __sane_unused__ version_code, SANE_Auth_Callback __sane_un
DBG (3, "sane-init: I don't know how to handle option `%s'\n", DBG (3, "sane-init: I don't know how to handle option `%s'\n",
word); word);
} /* while */ } /* while */
if (word)
free (word);
fclose (fp); fclose (fp);
} /* if */ } /* if */
else else