Merge "Optional autogen.sh flag --enable-kdbus-transport added allowing to compile...
[platform/upstream/dbus.git] / bus / desktop-file.c
index bfe0240..bfeb72e 100644 (file)
@@ -1,4 +1,4 @@
-/* -*- mode: C; c-file-style: "gnu" -*- */
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
 /* desktop-file.c  .desktop file parser
  *
  * Copyright (C) 2003  CodeFactory AB
  * 
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
+
+#include <config.h>
 #include <dbus/dbus-sysdeps.h>
 #include <dbus/dbus-internals.h>
 #include "desktop-file.h"
@@ -66,7 +68,7 @@ typedef struct
 
 #define VALID_KEY_CHAR 1
 #define VALID_LOCALE_CHAR 2
-unsigned char valid[256] = { 
+static unsigned char valid[256] = { 
    0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 
    0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 
    0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x0 , 0x3 , 0x2 , 0x0 , 
@@ -330,7 +332,7 @@ new_line (BusDesktopFileParser *parser)
 
   line = &section->lines[section->n_lines++];
 
-  memset (line, 0, sizeof (BusDesktopFileLine));
+  _DBUS_ZERO(*line);
     
   return line;
 }
@@ -686,6 +688,12 @@ bus_desktop_file_load (DBusString *filename,
       else if (is_blank_line (&parser) ||
               _dbus_string_get_byte (&parser.data, parser.pos) == '#')
        parse_comment_or_blank (&parser);
+      else if (parser.current_section < 0)
+       {
+           dbus_set_error(error, DBUS_ERROR_FAILED,
+                          "invalid service file: key=value before [Section]");
+           return NULL;
+       }
       else
        {
          if (!parse_key_value (&parser, error))