[gnuwin32 - Help] Libarchive segfault on archive_write_header

"SourceForge.net" <[email protected]>
Newsgroups gmane.comp.windows.gnu.user
Message-ID <[email protected]>
Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=5026519
By: jholl

I'm getting a segfault using libarchive when trying running an example from
archive_write_new manpage.I step through the app and get the following stack
when after the call to archive_write_header. I thought maybe the it was having
issues with the file not existing but i opened the file before the
archive_write_heaer call and it was there where not issues with that.

Stack

Thread [1] (Suspended: Signal 'SIGSEGV' received. Description: Segmentation
fault.)
	3 wcsxfrm()  0x77c483b7	
	2 stricmp()  0x77c4627d	
	1 libarchive2!archive_write_open()  0x62594d4b	
Code

int main () {
	
	struct myArchData *mydata = malloc(sizeof(struct myArchData));
	struct archive *a;
	struct archive_entry *entry;
	struct stat st;
	
	char buff[8192];
	int len;
	int fd;
	
	a = archive_write_new();
	mydata->name = "C:\\test.tar";
	  archive_write_set_compression_gzip(a);
	  archive_write_set_format_ustar(a);
	  archive_write_open(a, mydata, myopen, mywrite, myclose);
	  
	  char **filename = (char**)malloc(1* sizeof(*filename));
	  filename[0] = "C:\\powerdvd.log";
	  int fileHanlde = open(*filename, O_RDONLY);
	  close(fileHanlde);
	  while (*filename) {
	    stat(*filename, &st);
	    entry = archive_entry_new();
	    archive_entry_copy_stat(entry, &st);
	    archive_entry_set_pathname(entry, *filename);
	    archive_write_header(a, entry);
	    fd = open(*filename, O_RDONLY);
	    len = read(fd, buff, sizeof(buff));
	    while ( len > 0 ) {
		archive_write_data(a, buff, len);
		len = read(fd, buff, sizeof(buff));
	    }
	    archive_entry_free(entry);
	    filename = filename + 1;
	  }
	  archive_write_finish(a);

	return 0;
	
	
	
}

compile and link commands
g++ -O0 -g3 -Wall -c -fmessage-length=0 -otransfer\fileDownload.o
..\transfer\fileDownload.cpp
g++ -LC:\Program Files\GnuWin32\lib -LC:\lang_env\c\lib -oAutoloader.exe
transfer\fileDownload.o main.o -llibarchive

if anyone has suggestions let me know


______________________________________________________________________
You are receiving this email because you elected to monitor this forum.
To stop monitoring this forum, login to SourceForge.net and visit: 
https://sourceforge.net/forum/unmonitor.php?forum_id=74807

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.