delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/23/16:32:46

X-Authentication-Warning: niemeyer.net: Host 200.230.186.180-as.acessonet.com.br [200.230.186.180] claimed to be computer
From: "Gustavo Niemeyer" <djgpp AT niemeyer DOT net>
To: <djgpp AT delorie DOT com>
Subject: RE: GPEs...
Date: Wed, 23 Jun 1999 17:31:11 -0300
Message-ID: <LOBBKLEPLBKLOKFELHOIOEOMCCAA.djgpp@niemeyer.net>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0)
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
In-Reply-To: <IhZb3.48$G81.2462@newsgate.direct.ca>
Importance: Normal
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

Maybe because if c=='>' you try to free container two
times so you free something that is not allocated. I got
some errors some time ago trying to do this.

Gustavo Niemeyer


-----Original Message-----
From: Daniel Eaton [mailto:deaton AT direct DOT ca]
Sent: Quarta-feira, 23 de Junho de 1999 01:27
To: djgpp AT delorie DOT com
Subject: GPEs...


Does anyone know why the mallocs give me a GPE about 50% of runs?

Thanks,
    Daniel Eaton

char *html_parse_tag_get(int filepos,FILE *fp)
{
  fseek(fp,filepos,SEEK_SET);

  int c;
  c=fgetc(fp);

  if(!c=='<')
    return _ERROR;

  char *tag=NULL,*container=NULL;

  int tagl=0;

  for(;;)
  {
    c=fgetc(fp);

    if(c=='>')
    {
      free(container);
      tag[tagl-1]='\0';
      return tag;
    }

    tagl++;

    free(container);
    container=(char *)malloc(tagl-1);
    strcpy(container,tag);

    free(tag);
    tag=(char *)malloc(tagl);
    strcpy(tag,container);
    tag[tagl-1]=c;
  }
}




- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019