Clean up properly if we get an error after allocating the private data

structure.

svn path=/trunk/; revision=32563
This commit is contained in:
Guy Harris 2010-04-26 02:26:22 +00:00
parent c7e88aa69f
commit adf7e45432
1 changed files with 10 additions and 4 deletions

View File

@ -240,13 +240,19 @@ int nettl_open(wtap *wth, int *err, gchar **err_info _U_)
/* read the first header to take a guess at the file encap */
bytes_read = file_read(dummy, 1, 4, wth->fh);
if (bytes_read != 4) {
if (*err != 0)
return -1;
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
if (*err != 0) {
wth->priv = NULL;
g_free(nettl);
return -1;
}
if (bytes_read != 0) {
*err = WTAP_ERR_SHORT_READ;
wth->priv = NULL;
g_free(nettl);
return -1;
}
wth->priv = NULL;
g_free(nettl);
return 0;
}