Bonjour, je fais un simple malloc et j'ai tout ça comme erreur :
*** glibc detected *** /home/lindows/public_html/cgi-bin/relais_lignes.cgi: malloc(): memory corruption: 0x08187d08 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6[0xb7d1e176]
/lib/tls/i686/cmov/libc.so.6(__libc_calloc+0xef)[0xb7d1f5ef]
/usr/lib/libX11.so.6[0xb7e2db3b]
/usr/lib/libX11.so.6(XInternAtom+0x56)[0xb7e2e0e6]
/home/lindows/public_html/cgi-bin/relais_lignes.cgi[0x804895d]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe5)[0xb7cc2685]
/home/lindows/public_html/cgi-bin/relais_lignes.cgi[0x80487a1]


.................
Le bout de code qui cause probl :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 
int main(int argc, char *argv[]){
  char *var, *ip, *fq;
  Window win, w;
  Atom qs;
  int cpt;
 
  if (! (dpy = XOpenDisplay(":0.0"))) {
    fprintf(stderr, "%s: dispositif %s injoignable\n", argv[0],
              XDisplayName(":0.0"));
    exit(-1);
  }
 
 
  win = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy), 
			    0,0,15,15,0, 
			    BlackPixel(dpy, DefaultScreen(dpy)),
			    WhitePixel(dpy, DefaultScreen(dpy)) );
 
 
  var = getenv("QUERY_STRING");
  ip =  getenv("REMOTE_ADDR");
 
  cpt = (int)(strlen(ip) + strlen(var) + 12);
  // -------> ici ca bloque fq = malloc(sizeof(char)* cpt);
  strcat(fq,var);
  strcat(fq,"&addresseIP=");
  strcat(fq,ip);
  qs = XInternAtom(dpy, "xhextris_query_string",True);
  w = XGetSelectionOwner(dpy,qs);
 
  fprintf(stdout,"Content-Type: text/html\n\n");  
  fprintf(stdout, "<html><head></head><body>");  
  fprintf(stdout,"<p>QUERY_STRING : %s</p>",fq);
  fprintf(stdout,"</body></html>\n");  
 
  XChangeProperty(dpy,w,
		  qs,
		  XA_STRING,
		  8,
		  PropModeReplace,
                  (unsigned char *) var,
                  strlen(var)+1);
  XFlush(dpy);
 
  return 0;
}
Quelqu'un peut - il m'aider?