]> git.sesse.net Git - vlc/commitdiff
python bindings, vlc_position.c: check against invalid origin or key values
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 29 May 2007 10:01:36 +0000 (10:01 +0000)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Tue, 29 May 2007 10:01:36 +0000 (10:01 +0000)
bindings/python/vlc_position.c

index 4e330c8d6dbfcbbb84b391320c96b23908398dff..919be29b26cd03c480efb92ca1acb489a5526305 100644 (file)
@@ -38,8 +38,6 @@ PyPosition_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
     self->origin=mediacontrol_AbsolutePosition;
     self->key=mediacontrol_MediaTime;
 
-    /* We do not care about the return value, since it will leave the fields
-       with their default value. */
     if(! PyArg_ParseTupleAndKeywords( args, kwds, "|lii", kwlist,
                                       &(self->value),
                                       &(self->origin),
@@ -47,7 +45,23 @@ PyPosition_new( PyTypeObject *type, PyObject *args, PyObject *kwds )
     {
         return NULL;        
     }
-       
+
+    if( self->key != mediacontrol_MediaTime 
+       && self->key != mediacontrol_ByteCount
+       && self->key != mediacontrol_SampleCount ) 
+    {
+        PyErr_SetString ( MediaControl_InternalException, "Invalid key value" );
+        return NULL;
+    }
+
+    if( self->origin != mediacontrol_AbsolutePosition 
+       && self->origin != mediacontrol_RelativePosition
+       && self->origin != mediacontrol_ModuloPosition ) 
+    {
+        PyErr_SetString ( MediaControl_InternalException, "Invalid origin value" );
+        return NULL;
+    }
+
     Py_INCREF( self );
     return ( PyObject * )self;    
 }