SIGSEGV in the next code lazarus / 31-LCL ---------------------------------------------------------------------- pedrote · 2012-12-16 14:21 Hello, the problem is when I press the button, the first time I get the data of the query but the second time i get a excepcion. How can i solved it?. Thanks, The code is: Code: [Select]...... ..... function TForm1.GetValIni(secc, val: string): string; begin   INI := TINIFILE.Create(Config);   Result := INI.ReadString(secc, val, '');   INI.Free; end; // Configura los parámetros de conexión a MSSQL function TForm1.ObtenerDatosConnDB: boolean; begin   if CheckValIni('BD', 'Inst') and CheckValIni('BD', 'Usuario') and     CheckValIni('BD', 'Usuario') then   begin     MSSQLConnection1.HostName := GetValIni('BD', 'Inst');     MSSQLConnection1.UserName := GetValIni('BD', 'Usuario');     MSSQLConnection1.Password := descifrar(GetValIni('BD', 'Pass'));     Result := True;     exit;   end;   Result := False; end; // Obtiene el nombre de la BD del ejercicio de año actual function TForm1.ObtenerBDEjActual: string; begin   if ObtenerDatosConnDB then   begin     MSSQLConnection1.DatabaseName := 'COMU0001';     MSSQLConnection1.Connected := True;     if MSSQLConnection1.Connected then     begin       SQLQuery1.SQL.Text := 'SELECT [CONEXION] ' +                             'FROM ejercici ' +                             'WHERE [ANY] = '                                    + '''' + FormatDateTime('yyyy', Now) + ''';';       SQLQuery1.Open;       Result := SQLQuery1.FieldByName('CONEXION').AsString;       SQLQuery1.Close;       exit;     end;     MSSQLConnection1.Connected := False;   end; end;              ... ... procedure TForm1.Button3Click(Sender: TObject); var   prueba: string; begin     prueba := ObtenerBDEjActual;     ShowMessage(prueba); end; ---------------------------------------------------------------------- User137 · 2012-12-16 14:53 What's in CheckValIni()? Just making sure that ini is again created and freed, i don't see error in code you showed. descifrar() is also unknown, but it's not what i would suspect for error. It just does something to password string it seems. ---------------------------------------------------------------------- pedrote · 2012-12-16 15:00 I think the problem is in the ObtenerBDEjActual function because the first time that I press the buttom works but the next times don't work. descifrar() and CheckValIni() code: Code: [Select] // Función para obtener claves en texto plano function TForm1.descifrar(pass: string): string; var   Salida: string; begin   DCP_idea1.Create(nil);   DCP_idea1.InitStr('xx', TDCP_sha256);   Salida := DCP_idea1.DecryptString(pass);   DCP_idea1.Burn;   FreeAndNil(DCP_idea1);   Result := Salida; end; // Comprobamos si se encuentra el valor para la clave indicada y en la sección // indicada en el fichero ini function TForm1.CheckValIni(secc, val: string): boolean; var   check: string; begin   INI := TINIFILE.Create(Config);   check := INI.ReadString(secc, val, '');   if check = '' then   begin     Result := False;     INI.Free;     exit;   end;   Result := True;   INI.Free; end; ---------------------------------------------------------------------- Leledumbo · 2012-12-16 15:13 On which line of your code the exception happens? To know, just run, then when the exception occurs, choose Break in the shown dialog, the open View->Debug Windows->Call Stack and scroll down to first entry that is part of your code (press More if you can't find any, it may be deeper). ---------------------------------------------------------------------- pedrote · 2012-12-16 15:45 In this line: Code: [Select] DCP_idea1.Create(nil);  What's the problem? ---------------------------------------------------------------------- Blaazen · 2012-12-16 16:15 It must be: Code: [Select]DCP_idea1:= TDCPxxx.Create(nil); I don't know what class it is but I hope you understand what I mean ---------------------------------------------------------------------- pedrote · 2012-12-16 16:29 Ok, thanks. The problem is resolved.