After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 561807 - inotify_sub.c :: dup_dirname() fails to remove trailing '/'
inotify_sub.c :: dup_dirname() fails to remove trailing '/'
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gio
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2008-11-21 13:58 UTC by Dan Williams
Modified: 2008-11-28 05:10 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Dan Williams 2008-11-21 13:58:39 UTC
35 static gchar*
36 dup_dirname (const gchar *dirname)
37 {
38     gchar *d_dirname = g_strdup (dirname);
39     size_t len = strlen (d_dirname);
40 
41     if (d_dirname[len] == '/')
42         d_dirname[len] = '\0';
43 
44     return d_dirname;
45 }


Lines 41 & 42: string[<len of string>] is always 0.  Should be:

41     if (d_dirname[len - 1] == '/')
42         d_dirname[len - 1] = '\0';

Otherwise, trailing '/' never gets stripped.
Comment 1 Matthias Clasen 2008-11-28 05:10:58 UTC
2008-11-28  Matthias Clasen  <mclasen@redhat.com>

        Bug 561807 – inotify_sub.c :: dup_dirname() fails to remove trailing
        '/'

        * inotify/inotify-sub.c (dup_dirname): Actually strip the trailing
        '/' away. Spotted by Dan Williams.