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:
  Show dependency tree
 
Reported: 2008-11-21 13:58 UTC by Dan Williams
Modified: 2008-11-28 05:10 UTC (History)
2 users (show)

See Also:
GNOME target: ---
GNOME version: ---


Attachments

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.


Note You need to log in before you can comment on or make changes to this bug.