mahiapkum
12th April 2007, 12:27
Hi ,
I have an application developed in qt and when i run it i get segmentation fault the piece of code that generates the error is as follows:
void OffLineKDFWindow::ReadKAMALOffLineFile()
{
char str[256] , *ptr;
char *cptr;
QString s = QFileDialog::getOpenFileName(
"/home",
"Images (*.gsf)",
this,
"open file dialog",
"Choose a .gsf file to open" );
if(s != NULL)
{
strcpy(str,s);
int row = 0;
int col = 0;
GULAB_FILE_t *gfp = NULL;
QString KDFline;
int retval_size=1;
GULAB_PACKET_t gsf_row;
int i, PCount,err;
unsigned char formatted_mac_address[18];
table->setColumnWidth (0, 100 );
table->setColumnWidth (1, 100 );
table->setColumnWidth (2, 140 );
table->setColumnWidth (3, 160 );
table->setColumnWidth (4, 150 );
table->setColumnWidth (5, 150 );
table->setColumnWidth (6, 120 );
table->setColumnWidth (7, 200 );
table->setColumnWidth (8, 200 );
table->setColumnWidth (9, 120 );
table->setColumnWidth (10, 150 );
table->setColumnWidth (11,6000 );
int noRows , noColumns;
noRows = table->numRows();
noColumns = table->numCols();
char arr[] = "GULAB off line File reader:";
strcat(arr, s);
setCaption(tr(arr));
if((gfp = gsf_open((unsigned char*)str, READ, NULL, INIT_YES))== NULL)
{
printf("3 Compiler is here..%d\n",gfp->header.total_session_count);
return;
}
for(i=0;i<gfp->header.total_session_count;i++)
{
char tempData[12000] = { 0 };
if((err=gsf_read_next_packet(gfp,(GULAB_PACKET_t *)tempData)) == 0)
{
{
struct in_addr temp;
memcpy((char *)&gsf_row,tempData,sizeof(GULAB_PACKET_t));
temp.s_addr= gsf_row.gph.session_details.source_ip_address;
printf("Setting Text\n");
table->setText( row, 1, (char *)inet_ntoa(temp));
printf("Set text\n");
}
}
printf("Out of if\n");
}
}
printf("Out of 2nd if\n");}
}
There is no problem with gsf_read_next_packet() function the printfs "Setting Text" and "Set text" is getting printed it comes out of for loop but the statement "Out of 2nd if" does not get printed it is where i get segmentation fault.I have included all the required header files.The point of error is after "Out of if\n" statement.can any one help me:confused:
I have an application developed in qt and when i run it i get segmentation fault the piece of code that generates the error is as follows:
void OffLineKDFWindow::ReadKAMALOffLineFile()
{
char str[256] , *ptr;
char *cptr;
QString s = QFileDialog::getOpenFileName(
"/home",
"Images (*.gsf)",
this,
"open file dialog",
"Choose a .gsf file to open" );
if(s != NULL)
{
strcpy(str,s);
int row = 0;
int col = 0;
GULAB_FILE_t *gfp = NULL;
QString KDFline;
int retval_size=1;
GULAB_PACKET_t gsf_row;
int i, PCount,err;
unsigned char formatted_mac_address[18];
table->setColumnWidth (0, 100 );
table->setColumnWidth (1, 100 );
table->setColumnWidth (2, 140 );
table->setColumnWidth (3, 160 );
table->setColumnWidth (4, 150 );
table->setColumnWidth (5, 150 );
table->setColumnWidth (6, 120 );
table->setColumnWidth (7, 200 );
table->setColumnWidth (8, 200 );
table->setColumnWidth (9, 120 );
table->setColumnWidth (10, 150 );
table->setColumnWidth (11,6000 );
int noRows , noColumns;
noRows = table->numRows();
noColumns = table->numCols();
char arr[] = "GULAB off line File reader:";
strcat(arr, s);
setCaption(tr(arr));
if((gfp = gsf_open((unsigned char*)str, READ, NULL, INIT_YES))== NULL)
{
printf("3 Compiler is here..%d\n",gfp->header.total_session_count);
return;
}
for(i=0;i<gfp->header.total_session_count;i++)
{
char tempData[12000] = { 0 };
if((err=gsf_read_next_packet(gfp,(GULAB_PACKET_t *)tempData)) == 0)
{
{
struct in_addr temp;
memcpy((char *)&gsf_row,tempData,sizeof(GULAB_PACKET_t));
temp.s_addr= gsf_row.gph.session_details.source_ip_address;
printf("Setting Text\n");
table->setText( row, 1, (char *)inet_ntoa(temp));
printf("Set text\n");
}
}
printf("Out of if\n");
}
}
printf("Out of 2nd if\n");}
}
There is no problem with gsf_read_next_packet() function the printfs "Setting Text" and "Set text" is getting printed it comes out of for loop but the statement "Out of 2nd if" does not get printed it is where i get segmentation fault.I have included all the required header files.The point of error is after "Out of if\n" statement.can any one help me:confused: