unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 648161d620718206bbd4114f87be55294a915dda 1043 bytes (raw)
name: gnu/packages/patches/audiofile-fix-sign-conversion.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
Based on (hunk for changelog removed)
From b62c902dd258125cac86cd2df21fc898035a43d3 Mon Sep 17 00:00:00 2001
From: Michael Pruett <michael@68k.org>
Date: Mon, 29 Aug 2016 23:08:26 -0500
Subject: [PATCH] Fix undefined behavior in sign conversion.


---
 ChangeLog                           | 5 +++++
 libaudiofile/modules/SimpleModule.h | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/libaudiofile/modules/SimpleModule.h b/libaudiofile/modules/SimpleModule.h
index 03c6c69..bad85ad 100644
--- a/libaudiofile/modules/SimpleModule.h
+++ b/libaudiofile/modules/SimpleModule.h
@@ -123,7 +123,8 @@ struct signConverter
 	typedef typename IntTypes<Format>::UnsignedType UnsignedType;
 
 	static const int kScaleBits = (Format + 1) * CHAR_BIT - 1;
-	static const int kMinSignedValue = -1 << kScaleBits;
+	static const int kMaxSignedValue = (((1 << (kScaleBits - 1)) - 1) << 1) + 1;
+	static const int kMinSignedValue = -kMaxSignedValue - 1;
 
 	struct signedToUnsigned : public std::unary_function<SignedType, UnsignedType>
 	{

debug log:

solving 648161d620 ...
found 648161d620 in https://git.savannah.gnu.org/cgit/guix.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).