[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Is there a bug in headerFree? (rpm-4.0.3)



  Hi,

I'm trying to print all the installed packages.
The following program used to work with rpm-4.0.
Now, it segfault on headerFree().
It works well if I comment out the call to headerFree(), but I guess it then
leaks some memory.

shouldn't we free headers in rpm-4.0.3 anymore?

-------------------------------------------------------------------
#include <sys/stat.h>
#include <fcntl.h>


#include <rpm/rpmlib.h>
#include <rpm/rpmio.h>
#include <rpm/misc.h>


int main(void)
{
  rpmdb db;
  Header h;
  char *buf;
  int *size;
  int type, count;
  rpmdbMatchIterator iterator;

  rpmReadConfigFiles(NULL, NULL);
  if (rpmdbOpen("", &db, O_RDONLY, 0644))
  {
    printf("Error!\n");exit(-1);
  }
  iterator = rpmdbInitIterator(db, RPMDBI_PACKAGES, NULL, 0);
  while ((h = rpmdbNextIterator(iterator)) != NULL)
  {
    if (!h)
    {
      printf("Error!\n");
    }
    headerGetEntry(h, RPMTAG_NAME, &type, (void **) &buf, &count);
    printf("%s", buf);
    headerGetEntry(h, RPMTAG_SIZE, &type, (void **) &size, &count);
    headerGetEntry(h, RPMTAG_VERSION, &type, (void **) &buf, &count);
    printf("-%s", buf);
    headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) &buf, &count);
    printf("-%s", buf);
    headerGetEntry(h, RPMTAG_ARCH, &type, (void **) &buf, &count);
    printf(".%s", buf);

    printf("\n");
    headerFree(h);
  }
  rpmdbFreeIterator(iterator);
  rpmdbClose(db);

  return 0;
}
--------------------------------------------------------------------

           Thanks,

                  DindinX

-- 
  odin@mandrakesoft.com





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] []