Bug 130735
Summary: | strsep() function usage ends with "Segmentation fault" | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Evgeny Sizikov <eugene_beast> |
Component: | glibc | Assignee: | Jakub Jelinek <jakub> |
Status: | CLOSED NOTABUG | QA Contact: | Brian Brock <bbrock> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 2 | ||
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | i386 | ||
OS: | Linux | ||
URL: | https://www.223-223.ru/svn/repos/phonestat/phonestat/tests/test_strsep.c | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2004-08-30 15:07:03 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Evgeny Sizikov
2004-08-24 01:45:12 UTC
Ah, yes - if strsep() finds no any of the separators provided in the working buffer, it doesn't produces "Segmentation fault" Your testcase is wrong. The segfault is not in strsep, but when trying to free(buf). As you used buf as strtok_r's *ptrptr pointer (and data as strsep's *stringp pointer), the buf you pass to free is what malloc gave you plus 8 (length of the test string) and data will be NULL at the end. You probably want to change dataptr from char ** to char * and pass &dataptr to strtok_r and strsep. |