[MPlayer-dev-eng] [PATCH] fix for segmentation fault in ao_nas

Erik Auerswald auerswal at unix-ag.uni-kl.de
Tue Jun 14 08:25:53 CEST 2005


Hi,

On Mon, Jun 13, 2005 at 06:12:38PM +0200, Guillaume POIRIER wrote:
> Has anyone had a look at it?

I've changed the patch a bit without changing the way it works:
- chosen alternative 2
- added #include <inttypes.h>
- removed redundant check for negative server_buffer_used

Erik
-------------- next part --------------
diff -Naur main/libao2/ao_nas.c main.fixed/libao2/ao_nas.c
--- main/libao2/ao_nas.c	2005-02-28 00:06:32.000000000 +0100
+++ main.fixed/libao2/ao_nas.c	2005-06-04 19:36:29.856128874 +0200
@@ -32,6 +32,7 @@
 #include <string.h>
 #include <pthread.h>
 #include <audio/audiolib.h>
+#include <inttypes.h>
 
 #include "config.h"
 #include "mp_msg.h"
@@ -117,10 +118,10 @@
 
 	void *client_buffer;
 	void *server_buffer;
-	int client_buffer_size;
-	int client_buffer_used;
-	int server_buffer_size;
-	int server_buffer_used;
+	int64_t client_buffer_size;
+	int64_t client_buffer_used;
+	int64_t server_buffer_size;
+	int64_t server_buffer_used;
 	pthread_mutex_t buffer_mutex;
 
 	pthread_t event_thread;
@@ -254,9 +255,9 @@
 		event->num_bytes,
 		nas_data->expect_underrun);
 
+	if(event->num_bytes > nas_data->server_buffer_used)
+		event->num_bytes = nas_data->server_buffer_used;
 	nas_data->server_buffer_used -= event->num_bytes;
-	if (nas_data->server_buffer_used < 0)
-		nas_data->server_buffer_used = 0;
 
 	switch (event->reason) {
 	case AuReasonWatermark:


More information about the MPlayer-dev-eng mailing list