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 781955 - Segmentation fault when week start in past month
Segmentation fault when week start in past month
Status: RESOLVED FIXED
Product: gnome-calendar
Classification: Applications
Component: Views
3.25.x
Other Linux
: Normal normal
: 3.26
Assigned To: GNOME Calendar maintainers
GNOME Calendar maintainers
Depends on:
Blocks:
 
 
Reported: 2017-04-30 00:40 UTC by kestanegurgen
Modified: 2017-05-09 20:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (1.18 KB, patch)
2017-04-30 00:40 UTC, kestanegurgen
none Details | Review
Patch 2 (1.67 KB, patch)
2017-04-30 14:46 UTC, kestanegurgen
none Details | Review
Fixed patch (2.93 KB, patch)
2017-05-02 23:22 UTC, kestanegurgen
none Details | Review
Fixed patch2 (2.94 KB, patch)
2017-05-02 23:34 UTC, kestanegurgen
none Details | Review
PatchV4 (2.91 KB, patch)
2017-05-03 16:41 UTC, kestanegurgen
none Details | Review
PatchV5 (2.91 KB, patch)
2017-05-04 01:36 UTC, kestanegurgen
none Details | Review
PatchV6 (3.12 KB, patch)
2017-05-05 21:14 UTC, kestanegurgen
committed Details | Review

Description kestanegurgen 2017-04-30 00:40:16 UTC
Created attachment 350751 [details] [review]
Patch

April:
30 01 02 03 04 05 06

Drag and drop of multiday event in this week, you will get a Segmentation Fault.

Small bug
Comment 1 kestanegurgen 2017-04-30 14:46:02 UTC
Created attachment 350766 [details] [review]
Patch 2
Comment 2 Georges Basile Stavracas Neto 2017-05-01 14:30:01 UTC
Review of attachment 350751 [details] [review]:

Nice catch, almost there! There are 2 problems with this patch:

 1. It causes a memory leak. GDateTime is an immutable object, and every operation creates a new object. You should unref() the previous datetime after adding the days.
 2. The code does not follow the GNU C Coding Style

About the commit itself, please follow the gudelines at https://wiki.gnome.org/Newcomers/SubmitPatch to write the commit message. And also, looks like your author name is broken (all I can see is < ²`‰U> here)
Comment 3 Georges Basile Stavracas Neto 2017-05-01 14:31:58 UTC
Review of attachment 350766 [details] [review]:

Same of the first patch.
Comment 4 kestanegurgen 2017-05-02 23:22:59 UTC
Created attachment 350910 [details] [review]
Fixed patch

I hope this is right patch
Comment 5 kestanegurgen 2017-05-02 23:34:31 UTC
Created attachment 350911 [details] [review]
Fixed patch2

Obsolete other patches, and deleted unnecessary newline in last patch
Comment 6 Georges Basile Stavracas Neto 2017-05-03 14:50:06 UTC
Review of attachment 350911 [details] [review]:

Almost there! Besides the code comments below, I believe the title is wrong in "week-header: week-header:". Should be only one "week-header:" prefix, right?

::: src/views/gcal-week-header.c
@@ +1386,3 @@
   week_start = get_start_of_week (self->active_date);
 
+  GDateTime *tmp_dt;

This is wrongly placed. It should be at the beginning of the function, with the other declarations.

Besides that, you can use the g_autoptr() facility.

@@ +1412,3 @@
 
+  dnd_date = g_date_time_add_days (tmp_dt, drop_cell);
+  g_clear_pointer (&tmp_dt, g_date_time_unref);

By using g_autoptr(), you won't need to clear it.
Comment 7 kestanegurgen 2017-05-03 16:41:07 UTC
Created attachment 350994 [details] [review]
PatchV4

Thanks for review,

You're right,

Because of bug in gitg (https://bugzilla.gnome.org/show_bug.cgi?id=781263), i have to write patch by hand. It corrupts author info and commit messages.

I fixed commit title.

Also now, using g_autoptr.
Comment 8 Georges Basile Stavracas Neto 2017-05-04 01:08:15 UTC
Review of attachment 350994 [details] [review]:

Sorry for the back and forth. I forgot to ask you one thing: because we're using g_autoptr(), you also have to initialize tmp_dt to NULL in the beginning of the function, otherwise we might crash if we enter the "if (!GCAL_IS_EVENT_WIDGET (event_widget))" condition.

Also, looks like the other patch (for week grid) was marked as obsolete. Was that on purpose? Are you going to upload another patch about that?
Comment 9 kestanegurgen 2017-05-04 01:36:47 UTC
Created attachment 351018 [details] [review]
PatchV5

Thanks for review,

I never use glib library. I'm learning with these bugs. These "back and forth" is good for me. 

With patch, initialized tmp_dt to NULL.

I don't know "week grid patch"? I think it's not me or i misunderstood? :)
Comment 10 Georges Basile Stavracas Neto 2017-05-04 01:48:38 UTC
(In reply to kestanegurgen from comment #9)

> I don't know "week grid patch"? I think it's not me or i misunderstood? :)

Er, you're right, there never had a week grid patch. Sorry for the noise!
Comment 11 Georges Basile Stavracas Neto 2017-05-04 11:33:43 UTC
Review of attachment 351018 [details] [review]:

The patch looks mostly good (except one very minor nitpick I commented below), but it appearently doesn't apply cleanly on top of git master. Could you please rebase this patch? After that, it'll be good to go.

::: src/views/gcal-week-header.c
@@ +1354,3 @@
   g_autoptr (GDateTime) dnd_date;
   g_autoptr (GDateTime) new_end;
+  g_autoptr (GDateTime) tmp_dt = NULL;

Please initialize this tmp_dt a few lines below, together with week_start, dnd_date and new_end.
Comment 12 kestanegurgen 2017-05-05 21:14:14 UTC
Created attachment 351238 [details] [review]
PatchV6

Sorry for late response

I added new patch, rebase master and initilize tmp_dt with others.
Comment 13 Georges Basile Stavracas Neto 2017-05-06 01:55:21 UTC
Review of attachment 351238 [details] [review]:

Perfect. Thanks for the patch!
Comment 14 Georges Basile Stavracas Neto 2017-05-09 20:03:14 UTC
Thanks for the patch!