Author: matz Date: Thu May 15 15:54:57 2008 New Revision: 10109 URL: http://svn.opensuse.org/viewcvs/zypp?rev=10109&view=rev Log: Very mean cause for random segfaults of susetags2solv. Modified: trunk/sat-solver/tools/repo_susetags.c Modified: trunk/sat-solver/tools/repo_susetags.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_susetags.c?rev=10109&r1=10108&r2=10109&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_susetags.c (original) +++ trunk/sat-solver/tools/repo_susetags.c Thu May 15 15:54:57 2008 @@ -401,8 +401,20 @@ { for (p = lastreal; *p; p++) { + char fname_buf[128]; + const char *fname; str = id2str(pool, *p); sp = strrchr(str, '/'); + /* Need to copy filename now, before we add string that could + realloc the stringspace (and hence invalidate str). */ + fname = sp + 1; + if (strlen(fname) >= 128) + fname = strdup(fname); + else + { + memcpy(fname_buf, fname, strlen(fname) + 1); + fname = fname_buf; + } if (sp - str >= 128) { char *sdup = strdup(str); @@ -419,7 +431,9 @@ } if (!did) did = repodata_str2dir(pd->data, "/", 1); - repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, sp + 1); + repodata_add_dirstr(pd->data, handle, SOLVABLE_FILELIST, did, fname); + if (fname != fname_buf) + free((char*)fname); *p = 0; } } -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org