Search Results

Search found 2 results on 1 pages for 'extremeblue'.

Page 1/1 | 1 

  • glibc detected ./.a.out: free(): invalid pointer

    - by ExtremeBlue
    typedef struct _PERSON { size_t age; unsigned char* name; }PERSON; int init(PERSON** person) { (* person) = (PERSON *) malloc(sizeof(struct _PERSON)); (* person)->age = 1; (* person)->name = (unsigned char *) malloc(sizeof(4)); (* person)->name = "NAME"; return 0; } void close(PERSON** person) { (* person)->age = 0; if((* person)->name != NULL) { free((* person)->name); } if((* person) != NULL) { free((* person)); } } int main(int argc, char* argv[]) { PERSON* p; init(&p); printf("%d\t%s\n", (int) p->age, p->name); close(&p); return 0; } 1 NAME *** glibc detected *** ./a.out: free(): invalid pointer: 0x000000000040079c *** ======= Backtrace: ========= /lib/libc.so.6(+0x774b6)[0x7fa9027054b6] /lib/libc.so.6(cfree+0x73)[0x7fa90270bc83] ./a.out(close+0x3d)[0x400651] ./a.out[0x40069f] /lib/libc.so.6(__libc_start_main+0xfe)[0x7fa9026acd8e] ./a.out[0x4004f9] ... 7fa8fc000000-7fa8fc021000 rw-p 00000000 00:00 0 7fa8fc021000-7fa900000000 ---p 00000000 00:00 0 7fa902478000-7fa90248d000 r-xp 00000000 08:12 23068732 /lib/libgcc_s.so.1 7fa90248d000-7fa90268c000 ---p 00015000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268c000-7fa90268d000 r--p 00014000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268d000-7fa90268e000 rw-p 00015000 08:12 23068732 /lib/libgcc_s.so.1 7fa90268e000-7fa902808000 r-xp 00000000 08:12 23068970 /lib/libc-2.12.1.so 7fa902808000-7fa902a07000 ---p 0017a000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a07000-7fa902a0b000 r--p 00179000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a0b000-7fa902a0c000 rw-p 0017d000 08:12 23068970 /lib/libc-2.12.1.so 7fa902a0c000-7fa902a11000 rw-p 00000000 00:00 0 7fa902a11000-7fa902a31000 r-xp 00000000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c25000-7fa902c28000 rw-p 00000000 00:00 0 7fa902c2e000-7fa902c31000 rw-p 00000000 00:00 0 7fa902c31000-7fa902c32000 r--p 00020000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c32000-7fa902c33000 rw-p 00021000 08:12 23068966 /lib/ld-2.12.1.so 7fa902c33000-7fa902c34000 rw-p 00000000 00:00 0 7fff442d5000-7fff442f6000 rw-p 00000000 00:00 0 [stack] 7fff44308000-7fff44309000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] Aborted

    Read the article

  • How to remove .zip file in c on windows? (error: Directory not empty)

    - by ExtremeBlue
    include include include include "win32-dirent.h" include include include define MAXFILEPATH 1024 bool IsDirectory(char* path) { WIN32_FIND_DATA w32fd; HANDLE hFindFile; hFindFile = FindFirstFile((PTCHAR)path, &w32fd); if(hFindFile == INVALID_HANDLE_VALUE) { return false; } return w32fd.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY); } int RD(const char* folderName) { DIR *dir; struct dirent *ent; dir = opendir(folderName); if(dir != NULL) { while((ent = readdir(dir)) != NULL) { if(strcmp(ent->d_name , ".") == 0 || strcmp(ent->d_name, "..") == 0) { continue; } char fileName[MAXFILEPATH]; sprintf(fileName,"%s%c%s", folderName, '\\', ent->d_name); if(IsDirectory(fileName)) { RD(fileName); } else { unlink(fileName); } } closedir(dir); //chmod(folderName, S_IWRITE | S_IREAD); if(_rmdir(folderName) != 0)perror(folderName); } else { printf("%s <%s>\n","Could Not Open Directory.", folderName); return -1; } return 0; } int main(int argc, char* argv[]) { if(argc < 2) { printf("usage: ./a.out \n"); return 1; } //RD(argv[1]); //_mkdir("12"); //_mkdir("12\\34"); //_rmdir("12\\34"); //_rmdir("12"); char buf[0xff]; sprintf(buf, "unzip -x -q -d 1234 1234.zip"); system(buf); RD("1234"); //unlink("D:\\dev\\c\\project\\removeFolder\\Debug\\1234\\56\\5.txt"); //unlink("D:\\dev\\c\\project\\removeFolder\\Debug\\1234\\56\\6.txt"); //unlink("D:\\dev\\c\\project\\removeFolder\\Debug\\1234\\1_23.zip"); //unlink("D:\\dev\\c\\project\\removeFolder\\Debug\\1234\\4.txt"); //_rmdir("D:\\dev\\c\\project\\removeFolder\\Debug\\1234\\56"); //_rmdir("D:\\dev\\c\\project\\removeFolder\\Debug\\1234"); return 0; } Archive: 1234.zip inflating: 1234/4.txt inflating: 1234/56/5.txt inflating: 1234/56/6.txt inflating: 1234/1_23.zip

    Read the article

1