I just discovered a crash I didn't have before using IupConfigLoad()
after recently resyncing to to SVN.

If the config file is missing, my program crashes. Tracking it down,
it appears to be caused by a change that introduced a call to:
    iupLineFileClose(line_file);

as follows:


int IupConfigLoad(Ihandle* ih)
{
  char group[GROUPKEYSIZE] = "";
  char key[GROUPKEYSIZE];
  IlineFile* line_file;

  char* filename = iConfigSetFilename(ih);
  if (!filename)
    return -3;

  line_file = iupLineFileOpen(filename);
  if (!line_file)
  {
    iupLineFileClose(line_file);
    return -1;
  }

<snip>


If the config file is missing, line_file == NULL.
Then iupLineFileClose(line_file); is called.


That is defined as:

void iupLineFileClose(IlineFile* line_file)
{
  fclose(line_file->file);
  free(line_file->line_buffer);  /* use free because of realloc */
  free(line_file);
}


Which means, it is dereferencing a NULL pointer when doing line_file->file.


As far as I can tell, the config file will still only be created
calling IupConfigSave(), so there is no expectation that this file is
guaranteed to exist.

Can you confirm?

Thanks,
Eric

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to