void-packages/srcpkgs/astroid/patches/03e05bbdae9939cf4716ca2ff47dee75f1f3f57e.patch

53 lines
1.7 KiB
Diff

From 03e05bbdae9939cf4716ca2ff47dee75f1f3f57e Mon Sep 17 00:00:00 2001
From: Gaute Hope <eg@gaute.vetsj.com>
Date: Sat, 20 Oct 2018 19:38:01 +0200
Subject: [PATCH] ae: correctly allocate buffer array (-pedantic)
char[n] is technically not allowed in C++, and seems to cause trouble in
this case.
---
.../thread_view/webextension/ae_protocol.cc | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/src/modes/thread_view/webextension/ae_protocol.cc b/src/modes/thread_view/webextension/ae_protocol.cc
index 735b219b..6687b97b 100644
--- a/src/modes/thread_view/webextension/ae_protocol.cc
+++ b/src/modes/thread_view/webextension/ae_protocol.cc
@@ -59,7 +59,12 @@ namespace Astroid {
s &= ostream->write_all ((char*) &mt, sizeof (mt), written);
/* send message */
- s &= ostream->write_all (o, written);
+ try {
+ s &= ostream->write_all (o, written);
+ } catch (Gio::Error &ex) {
+ LOG (error) << "ae: error: " << ex.what ();
+ throw;
+ }
ostream->flush ();
if (!s) {
@@ -154,8 +159,13 @@ namespace Astroid {
}
/* read message */
- gchar buffer[msg_sz + 1]; buffer[msg_sz] = '\0';
- s = istream->read_all (buffer, msg_sz, read, reader_cancel);
+ gchar * buffer = new gchar[msg_sz];
+ try {
+ s = istream->read_all (buffer, msg_sz, read, reader_cancel);
+ } catch (Gio::Error &ex) {
+ LOG (error) << "ae: error (read): " << ex.code() << ", " << ex.what ();
+ throw;
+ }
if (!s || read != msg_sz) {
LOG (error) << "reader: error while reading message (size: " << msg_sz << ")";
@@ -163,6 +173,7 @@ namespace Astroid {
}
msg_str = std::string (buffer, msg_sz);
+ delete [] buffer;
return mt;
}