ERROR when sending sms with gps data

Hi,

I am beginner in programming and i want to do a gps/gsm tracking.
I use an Arduino uno R3 with GPS/GPRS/GSM Shield V3.0 from DFROBOT.
I want to send SMS to my phone with GPS data.

I use this code :

// Product name: GPS/GPRS/GSM Module V3.0
// # Product SKU : TEL0051
// # Version    : 0.1

// # Description:
// # The sketch for driving the gsm mode via the Arduino board

// # Steps:
// #        1. Turn the S1 switch to the Prog(right side)
// #        2. Turn the S2 switch to the Arduino side(left side)
// #        3. Take off the GSM/GPS jumper caps from the Uart select
// #        4. Upload the sketch to the Arduino board
// #        5. Turn the S1 switch to the comm(left side) 
// #        7. RST the board 

// #        wiki link- http://www.dfrobot.com/wiki/index.php/GPS/GPRS/GSM_Module_V3.0_(SKU:TEL0051)

char inChar;        // byte for GPS Serial Read
int index;          // index for string (GPSdata) from GPS
char GPSdata[300];  // string created with bytes (reading serial GPS)

byte gsmDriverPin[3] = {3,4,5};    //The default digital driver pins for the GSM and GPS mode
                                  //If you want to change the digital driver pins
                                  //or you have a conflict with D3~D5 on Arduino board,
                                  //you can remove the J10~J12 jumpers to reconnect other driver pins for the module!
void setup()
{    
  //Initialize the driver pins for GSM function:
  for(int i = 0 ; i < 3; i++){
    pinMode(gsmDriverPin[i],OUTPUT);
  }
  
  // Initialize a buffer for received GPS data GPSdata
    for (int i=0;i<300;i++){      
    GPSdata[i]=' ';
  } 
  
  // Output GSM Timing
  digitalWrite(5,HIGH);
  delay(1500);
  digitalWrite(5,LOW);
    
  // Enable GSM (Pin3,L)+ Disable GPS (Pin4,H):
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  delay(2000);
    
  //set the baud rate
  Serial.begin(9600); 
  delay(15000);    // time suggested by wiki
}  // end "void setup"

void loop(){
  // activate GPS with AT Commands 
  // NOTE: as suggested in "How to drive the GSM Mode via USB port" of wiki, 
  //      you have to send AT commands in GSM-mode, then switch in GPS-mode.
  Serial.print("AT");
  delay(2000);
  Serial.println("AT+CGPSIPR=9600");// (set the baud rate)
  delay(1000);
  Serial.println("AT+CGPSPWR=1");  // turn on GPS power supply
  delay(1000);
  Serial.println("AT+CGPSRST=1");  //reset GPS in autonomy mode
  
  // Enable GPS (Disable GSM)
  digitalWrite(3,HIGH);
  digitalWrite(4,LOW);
  
  //delay to assure GPS gets date.
  delay(60000); 
  
  // GPS COORDINATES ACQUISITION
  // Initialize a buffer for received GPS data GPSdata
  for (int i=0;i<300;i++){
    GPSdata[i]=' ';
  }
  // reset index
  index=0;
  
  // read Bytes from GPS:
  inChar = Serial.read();
  // See if the port is empty yet
  while (inChar == -1) {
    delay(100); 
  }
  // until buffer is full (GPSdata[300]):
  while (index<300){
    inChar = Serial.read();
    GPSdata[index] = inChar;
    index = index+1;
    }

  // Enable GSM (Pin3,L)+ Disable GPS (Pin4,H):
  digitalWrite(3,LOW);
  digitalWrite(4,HIGH);
  
  // send AT Commands (for SMS)
  Serial.println("AT"); //Send AT command  
  delay(2000);
  Serial.println("AT");  
  delay(2000);
  Serial.println("AT+CMGF=1");
  delay(1000);
  Serial.println("AT+CMGS=\"0629XXXXXX\"");  //Change the receiver phone number
  delay(1000);
  
  // send GPS store data:
  for (int i=0;i<300;i++){
    Serial.print(GPSdata[i]);
  }
  // add a word:
  Serial.print("GPS DATA");//the message you want to send
  delay(1000);
  Serial.println("");
  delay(1000);
  Serial.write(26); // ASCII Character = "CTRL-Z"
  while(1);
}

When i execute this code, i have a error in serial monitor :

I hope someone can help me, sorry for my english i'm french.
Thanks

// Initialize a buffer for received GPS data GPSdata
    for (int i=0;i<300;i++){      
    GPSdata[i]=' ';
  }

Horsecrap. You don't have a clue what NULL-terminated array of chars means, clearly.

Reading serial data until the first character arrives, and then expecting that somehow, magically, the other 300 bytes will arrive at once is wrong. There is no guarantee that there be 300 bytes of data.

There are plenty of crappy examples of reading GPS data, and some good ones, that are far better than your attempt.

 // See if the port is empty yet
  while (inChar == -1) {
    delay(100); 
  }

The comment should say: "If the input buffer is empty, hang forever."