[gnome-builder] ide-source-location: protect against negative values



commit f0f4df3d4a67c62db1c8695de018bacbcfd68be7
Author: Sebastien Lafargue <slafargue gnome org>
Date:   Wed Dec 2 18:09:30 2015 +0100

    ide-source-location: protect against negative values
    
    IdeSourceLocation uses a guint as line_offset but
    we often use it with gtk_text_buffer_get_iter_at_line_offset
    which uses a gint, so wrong large offset can turn
    into a negative value and fail
    
    Same for the line number.

 libide/ide-source-location.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libide/ide-source-location.c b/libide/ide-source-location.c
index 963a0a5..40be214 100644
--- a/libide/ide-source-location.c
+++ b/libide/ide-source-location.c
@@ -158,8 +158,8 @@ ide_source_location_new (IdeFile *file,
   ret = g_slice_new0 (IdeSourceLocation);
   ret->ref_count = 1;
   ret->file = g_object_ref (file);
-  ret->line = line;
-  ret->line_offset = line_offset;
+  ret->line = MIN (G_MAXINT, line);
+  ret->line_offset = MIN (G_MAXINT, line_offset);
   ret->offset = offset;
 
   EGG_COUNTER_INC (instances);


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