[gnac] Fixed bug #622238



commit 05957a5a6e7e6aeaabdcd9db3d7ae0bb26059a21
Author: Benoît Dupasquier <bdupasqu src gnome org>
Date:   Tue Jun 29 12:00:54 2010 +0100

    Fixed bug #622238

 libgnac/libgnac-output.c |   23 +++++++++++------------
 1 files changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/libgnac/libgnac-output.c b/libgnac/libgnac-output.c
index 6001436..d6ee92a 100644
--- a/libgnac/libgnac-output.c
+++ b/libgnac/libgnac-output.c
@@ -74,22 +74,21 @@ libgnac_output_rename_pattern_set_replace(LibgnacRenamePattern *pattern,
 static gchar *
 libgnac_output_remove_extension(const gchar *filename)
 {
-  gchar *ext;
-  gchar *output;
-  glong  ext_pos;
-  glong  output_long;
-
   g_return_val_if_fail(filename, NULL);
+  g_return_val_if_fail(g_utf8_validate(filename, -1, NULL), NULL);
 
-  ext = g_utf8_strrchr(filename, -1, '.');
-
-  ext_pos = ext ? g_utf8_strlen(ext, -1) : 0;
-  output_long = g_utf8_strlen(filename, -1) - ext_pos;
+  gchar *ext;
 
-  output = g_malloc((output_long + 1) * sizeof(gchar));
-  g_utf8_strncpy(output, filename, output_long);
+  ext = g_utf8_strrchr(filename, -1, '.');
+  if (ext) {
+    glong flen = g_utf8_strlen(filename, -1);
+    glong elen = g_utf8_strlen(ext, -1);
+    gchar output[flen-elen+1];
+    g_utf8_strncpy(output, filename, flen-elen);
+    return g_strdup(output);
+  }
 
-  return output;
+  return g_strdup(filename);
 }
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]