Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
763 connectés 

  FORUM HardWare.fr
  Programmation
  C++

  comment utiliser sizeof( )

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

comment utiliser sizeof( )

n°2073239
razuki
Posté le 02-05-2011 à 12:58:10  profilanswer
 

Bonjour,
mon programme fait un segmentation fault quand il execute l'instruction suivante :
memset(policy, 0, sizeof(srtp_policy_t));
oici le message de seg fault :

Code :
  1. Program received signal SIGSEGV, Segmentation fault.
  2. memset () at ../sysdeps/x86_64/memset.S:331
  3. 331 ../sysdeps/x86_64/memset.S: Aucun fichier ou dossier de ce type.
  4. in ../sysdeps/x86_64/memset.S


 
Voici le contexte:

Code :
  1. srtp_policy_t  *policy;
  2.   policy = si->u.rtp.info->policy;
  3.  
  4.   memset(policy, 0, sizeof(srtp_policy_t));
  5.   if(computeSessKey(si, policy, key_len) == -1)
  6.     return -1;


 
et voici srtp_policy_t :

Code :
  1. typedef struct srtp_policy_t {
  2.   ssrc_t        ssrc;        /**< The SSRC value of stream, or the  
  3.         *   flags SSRC_ANY_INBOUND or  
  4.         *   SSRC_ANY_OUTBOUND if key sharing
  5.         *   is used for this policy element.
  6.         */
  7.   crypto_policy_t rtp;         /**< SRTP crypto policy.                  */
  8.   crypto_policy_t rtcp;        /**< SRTCP crypto policy.                 */
  9.   unsigned char *key;          /**< Pointer to the SRTP master key for
  10.    *    this stream.                        */
  11.   struct srtp_policy_t *next;  /**< Pointer to next stream policy.       */
  12. } srtp_policy_t;


 
Apparemment c'est sizeof(srtp_policy_t qu'il n'aime pas ...
 
Comment je devrais indiquer à memset qu'il faut prendre la taille de srtp_policy_t ?
 
Merci d'avance pour votre aide.  

mood
Publicité
Posté le 02-05-2011 à 12:58:10  profilanswer
 

n°2073245
shaoyin
Posté le 02-05-2011 à 13:10:41  profilanswer
 

avant d'appeler memset, es-tu certain que policy n'est pas NULL ? ou qu'il ne pointe pas n'importe où ?

n°2073304
razuki
Posté le 02-05-2011 à 16:08:00  profilanswer
 

Effectivement, la mémoire pointée par policy a été desallouée ...


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C++

  comment utiliser sizeof( )

 

Sujets relatifs
[PHP] Utiliser 2 requêtes SQL dans 1 boucle ?Utiliser String et Nom JLabel
comment utiliser la bibliothèque Faxcom ? VBA & C++[RESOLU] Conseil dois-je utiliser Python
signer une donnée utiliser RSA / opensslComment utiliser les champs cachés ?
Extraire les noms des fichiers pour les utiliser en variableutiliser le langage C dans des fichiers cpp
[c++] utiliser caméra Smartphone Windows Mobile 6Utiliser un cache L1 de données comme un second cache L1 d'instruction
Plus de sujets relatifs à : comment utiliser sizeof( )


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR