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 619968 - Segfault: SafeUriExtension GetExtension() expects all files to have an extension
Segfault: SafeUriExtension GetExtension() expects all files to have an extension
Status: RESOLVED FIXED
Product: f-spot
Classification: Other
Component: General
GIT
Other Linux
: Normal critical
: 0.7.0
Assigned To: F-spot maintainers
F-spot maintainers
Depends on:
Blocks:
 
 
Reported: 2010-05-28 18:21 UTC by Johan Zaxmy
Modified: 2010-05-29 12:43 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix extension detection for files without extension. (4.78 KB, patch)
2010-05-29 12:42 UTC, Ruben Vermeersch
committed Details | Review

Description Johan Zaxmy 2010-05-28 18:21:58 UTC
Call to Substring will result in segfault when abs_uri doesnt contain an '.'

(mdb) list /home/johan/SRC/f-spot/src/Core/SafeUriExtensions.cs:23
  22         }
  23 
  24         public static string GetExtension (this SafeUri uri)
  25         {
  26             var abs_uri = uri.AbsoluteUri;
  27             return abs_uri.Substring (abs_uri.LastIndexOf ('.'));
  28         }

Fix, check the result of LastIndexOf and return empty string when no . found.
Comment 1 Ruben Vermeersch 2010-05-29 12:42:24 UTC
Created attachment 162266 [details] [review]
Fix extension detection for files without extension.

Also added a unit test to test these scenarios.
Comment 2 Ruben Vermeersch 2010-05-29 12:43:49 UTC
Fixed, thanks for reporting this!