SF.net SVN: geany:[5906] trunk
colombanw at users.sourceforge.net
colombanw at xxxxx
Fri Sep 2 21:44:44 UTC 2011
Revision: 5906
http://geany.svn.sourceforge.net/geany/?rev=5906&view=rev
Author: colombanw
Date: 2011-09-02 21:44:44 +0000 (Fri, 02 Sep 2011)
Log Message:
-----------
Fix foreach_ptr_array() not to crash on arrays with 0 elements
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2011-08-27 19:03:21 UTC (rev 5905)
+++ trunk/ChangeLog 2011-09-02 21:44:44 UTC (rev 5906)
@@ -1,5 +1,11 @@
2011-08-25 Colomban Wendling <colomban(at)geany(dot)org>
+ * src/utils.h:
+ Fix foreach_ptr_array() not to crash on arrays with 0 elements.
+
+
+2011-08-25 Colomban Wendling <colomban(at)geany(dot)org>
+
* src/document.c, src/filetypes.c, src/filetypes.h, doc/geany.txt,
doc/geany.html, data/filetypes.*:
Add support for filetype-specific indentation settings (closes
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2011-08-27 19:03:21 UTC (rev 5905)
+++ trunk/src/utils.h 2011-09-02 21:44:44 UTC (rev 5906)
@@ -84,8 +84,8 @@
* @param idx @c guint index into @a ptr_array.
* @param ptr_array @c GPtrArray to traverse. */
#define foreach_ptr_array(item, idx, ptr_array) \
- for (idx = 0, item = g_ptr_array_index(ptr_array, 0); \
- idx < ptr_array->len; ++idx, item = g_ptr_array_index(ptr_array, idx))
+ for (idx = 0, item = ((ptr_array)->len > 0 ? g_ptr_array_index((ptr_array), 0) : NULL); \
+ idx < (ptr_array)->len; ++idx, item = g_ptr_array_index((ptr_array), idx))
/** Iterates all the nodes in @a list.
* @param node should be a (@c GList*).
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list