Bonjour,

J'ai un code qui lors de mon realloc indique l'erreur realloc(): invalid next size: 0x00000000018d8010 ***.
Pouvez-vous m'aider ?
Voici la fonction qui me donne l'erreur :


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
int     make_map(char *file, t_serv *serv)
{
  int           l;
  int           size;
  FILE          *fd;
  char          *line;
  void          *test;
  size_t        i;
  if ((serv->map = malloc(sizeof(char *) * 2)) == NULL ||
      (line = malloc(sizeof(char))) == NULL)
    return (1);
  if ((fd = fopen(file, "r")) == NULL)
    return (2);
  serv->h = 0;
  i = 0;
  while (size = getline(&line, &i, fd) != -1)
    {
      serv->h++;
      if ((test = realloc(serv->map, sizeof(char *) * (serv->h + 2))) == NULL
          || (serv->map[serv->h] = malloc(sizeof(char) * (size + 1))) == NULL)
        return (1);
      l = -1;
      while (line[++l] != 0)
        serv->map[serv->h][l] = line[l];
    }
  return (end_map(serv));
}
C'est la ligne en gras (19) qui me retourne l'erreur.
Merci de toute aide que vous m'apporterez.