segmentation fault while returning from function.

I am working on the application in which I have to fetch values from the database and paste in url and send it to portal.

table=get_result("SELECT serialno,cas,Mode,FLC,TLC,location,CompName,CompCode,FG,FC,DispNo,TruckNo,LWbill,RRGPN,INVNO,DCN,RQTY,DQTY,SQTY,DDATE,RDATE,SDATE,TTIME FROM Drafts");

                   if(table.rows>1)
                                           
                    {//draft table opened               
                     
                     printf("\n Data in Drafts table...\n");
                                                            
                     for(i=0;i<table.rows;i++)
                                                                
                     {//outer loop
                                                                    
                         printf( " \t");
                                                                    
                         for(j=0;j<table.cols;j++)
                                                                        
                         {//inner loop 
                                                                    
                           printf("\n%d:%s",j,table.recordset[j]);  
                        
                         }//inner loop ends..
                        
                            choice=atoi(table.recordset[1]);//case

                            printf(" the choice is %d",choice);





switch(choice)
                            
{//Switch starts
                        
case 1:

sprintf(url,"http://%s:%s/FCMSBihar/Device/ReadData.aspx?Mode=%s&FLF=%s&FLC=%s&CC=%s&PPC=0&FG=%s&RRGPN=%s&LBillNo=%s&RQTY=%s&RDATE=%s%s&DDATE=%s",ipaddr,Port,table.recordset[2],table.recordset[5], table.recordset[3],table.recordset[7],table.recordset[9], table.recordset[10],table.recordset[13],table.recordset[16], table.recordset[20],table.recordset[22],table.recordset[19]);

printf("\nThe URL is %s",url);

                        GET_file_clear(url,"/mnt/jffs2/RP_rcpt.txt");//Launch the url to get the response.
                                                                                            
                        fp=fopen("/mnt/jffs2/RP_rcpt.txt","r");//Read response
                                                                
                        printf("\nthe file Contents are:");
                                                                
                        printf("Opening the file\n");
                                                                
                        while(fgets(buff_response,100,fp))    //buffer by buffer reading            
                                                                
                        {                        
                                                                  
                         printf("Reading the file\n");


                                                                
                        }

                        fclose(fp);

                        printf("\nthe response is: %s",buff_response);
                                                                
                        if(strstr(buff_response,"Successfull"))//checking the response.
                                                    
                            {//if successful clear the record from Drafts.

execute("DELETE FROM Drafts WHERE location ='%s'AND serialno='%s'AND Mode='%s';",table.recordset[5],table.recordset[0],table.recordset[2]);

                            sucess_count++;//increaments the success counter

                            }

                           else

                           {//if fails
                              
                              fail_count++;//increaments the fail counter

                            }

                        memset(url,'\0',sizeof(url));

                         break;

sprintf(str_sucess_report,"Record send is : %d",sucess_count);

sprintf(str_fail_report,"Record fail is : %d",fail_count);

printf("\n Records send is : %d ",sucess_count);//total successful transactions

printf("\n Records fail is : %d ",fail_count);//total failed transactions
                  
getchar();
free_result(table);
return 0;

In this code I had used the "table=get_result();" function in which I used to create database by giving the memory by malloc to rows and columns.
This whole process work well when i fetch 10to 11 records after that I creates the segmentation fault when I return after posting 30 to 40 data at the statement of "return 0 ".

please help me!!!!

You should doublecheck you're not exceeding array bounds anywhere or otherwise abusing local variables and hence corrupting your function's stack frame. That's probably what's causing this.